Skip to content

Fix multipart CSRF: keep body params string-keyed#519

Merged
timriley merged 1 commit into
mainfrom
ensure-string-csrf-token-in-params
Jun 22, 2026
Merged

Fix multipart CSRF: keep body params string-keyed#519
timriley merged 1 commit into
mainfrom
ensure-string-csrf-token-in-params

Conversation

@timriley

@timriley timriley commented Jun 22, 2026

Copy link
Copy Markdown
Member

BodyParser deep-symbolized its output, so multipart bodies would end up in params.raw with symbol keys. This led to issues with handling CSRF protection, because CSRFProtection would looks for the token under a String key (raw["_csrf_token"]), so would miss the token and reject the request.

Fix this by removing the symolizing from BodyParser, given that Params is doing symbolizing anyway. This allows the raw to keep the string keys that CSRFProtection expects.

Fixes #518

`BodyParser` deep-symbolized its output, so multipart bodies reached params.raw under Symbol keys. `CSRFProtection` would read the token with a String key (`raw["_csrf_token"]`), so it would miss the token and reject the request.

Fix this by removing the symolizing from `BodyParser`, given that `Params` is doing symbolizing anyway. This allows the `raw` to keep the string keys that `CSRFProtection` expects.
@timriley timriley force-pushed the ensure-string-csrf-token-in-params branch from 9a813a4 to f1bfc11 Compare June 22, 2026 13:49
@timriley timriley merged commit 2a0d812 into main Jun 22, 2026
11 checks passed
@timriley timriley deleted the ensure-string-csrf-token-in-params branch June 22, 2026 22:40
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.

CSRF token param key is sometimes a String, sometimes a Symbol

1 participant