Skip to content

Scan every request cookie, including ones SimpleCookie rejected - #769

Merged
hansott merged 4 commits into
mainfrom
fix/parse-cookies-like-frameworks
Oct 28, 2026
Merged

hansott merged 4 commits into
mainfrom
fix/parse-cookies-like-frameworks

Conversation

@iacobdaniel

@iacobdaniel iacobdaniel commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Python Zen parsed cookies with SimpleCookie, which drops every cookie as soon as one value contains a space, a comma or JSON, and it read only the last Cookie header. On Starlette and FastAPI, where Zen parses cookies itself, an injection in a cookie like id=1' OR '1'='1 was therefore never scanned. This PR splits each header on ;, keeps every pair and reads every Cookie header, the way those frameworks do, and it's about 10× faster than SimpleCookie. The gap only existed in the Python agent: the other agents either use the framework's own cookies or a parser that keeps every cookie.

@iacobdaniel iacobdaniel changed the title Parse request cookies without SimpleCookie Scan every request cookie, including ones SimpleCookie rejected Oct 27, 2026
Comment thread aikido_zen/context/asgi/__init__.py Outdated
Comment thread aikido_zen/context/parse_cookies.py Outdated
Comment thread aikido_zen/context/parse_cookies_test.py
@hansott
hansott merged commit 2657c8b into main Oct 28, 2026
131 checks passed
@hansott
hansott deleted the fix/parse-cookies-like-frameworks branch October 28, 2026 16:32
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.

3 participants