Repository navigation
Run request_validation_phase before storing omniauth.params - #1162
Merged
Merged
Conversation
A cross-site POST to /auth/:provider writes attacker-controlled query params into session['omniauth.params'] before AuthenticityTokenProtection runs, and the rejection path does not roll the write back. Move the session write after the validation phase, matching where omniauth.origin is already written.
sferik
force-pushed
the
validate-before-session-write
branch
from
October 17, 2026 16:40
ca96e90 to
17a95b1
Compare
sferik
approved these changes
Oct 17, 2026
sferik
left a comment
Contributor
There was a problem hiding this comment.
Thanks for finding this and for the clear write-up! Validating before touching the session is the right order, and I confirmed a rejected cross-site POST no longer overwrites omniauth.params.
sferik
added a commit
that referenced
this pull request
Oct 17, 2026
Cover the request phase and test mode: a POST that fails the authenticity check must not overwrite omniauth.params in the session. Both specs fail without the fix from #1162.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
request_callwritessession['omniauth.params'] = request.GETbefore callingrequest_validation_phase, and theAuthenticityErrorrescue path returns a failure response without rolling the write back. A cross-site POST to/auth/:providercan therefore replaceomniauth.paramsin a victim's session even though CSRF protection rejected it; the nextcallback_callhands those values to the app asenv['omniauth.params']. Because the request fails beforerequest_phase, an in-flight flow'somniauth.stateis untouched, so the callback still validates.This moves the write below the validation phase, where
omniauth.originis already written.before_request_phasehooks still see the value.Same reorder applied to
mock_request_callto keep test mode consistent.