Skip to content

Use the client IP and path set by earlier middleware - #823

Open
iacobdaniel wants to merge 3 commits into
fix/django-middleware-contextfrom
fix/middleware-current-request
Open

iacobdaniel wants to merge 3 commits into
fix/django-middleware-contextfrom
fix/middleware-current-request

Conversation

@iacobdaniel

@iacobdaniel iacobdaniel commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Apps that set the client IP or rewrite the path in their own middleware, before the Aikido middleware, had their requests checked against the original IP and path. The Aikido middlewares for Django, Flask and ASGI read the request again when an earlier middleware changed the WSGI environ or the ASGI scope, so rate limits and the bypassed IP list use the rewritten client and route, and so do the IP lists and route allowlists that Starlette, FastAPI and Quart check before the route. Under Django ASGI only changes to request.scope are seen, not changes to request.META. The headers, query and cookies from before the change are still scanned for attacks.

A middleware before ours can change the client IP or the path. The Aikido middlewares read the request again when such a value changed, and the values from before stay scanned.
Comment thread aikido_zen/context/asgi/__init__.py Resolved
Comment thread aikido_zen/context/asgi/__init__.py Resolved
@iacobdaniel iacobdaniel changed the title Check rate limits on the request as the Aikido middleware sees it Use the client IP and path set by earlier middleware Dec 4, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant