Skip to content

Run request_validation_phase before storing omniauth.params - #1162

Merged
sferik merged 1 commit into
omniauth:masterfrom
MegaManSec:validate-before-session-write
Oct 17, 2026
Merged

sferik merged 1 commit into
omniauth:masterfrom
MegaManSec:validate-before-session-write

Conversation

@MegaManSec

Copy link
Copy Markdown
Contributor

request_call writes session['omniauth.params'] = request.GET before calling request_validation_phase, and the AuthenticityError rescue path returns a failure response without rolling the write back. A cross-site POST to /auth/:provider can therefore replace omniauth.params in a victim's session even though CSRF protection rejected it; the next callback_call hands those values to the app as env['omniauth.params']. Because the request fails before request_phase, an in-flight flow's omniauth.state is untouched, so the callback still validates.

This moves the write below the validation phase, where omniauth.origin is already written. before_request_phase hooks still see the value.

Same reorder applied to mock_request_call to keep test mode consistent.

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
sferik force-pushed the validate-before-session-write branch from ca96e90 to 17a95b1 Compare October 17, 2026 16:40

@sferik sferik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
sferik merged commit 1e850e7 into omniauth:master Oct 17, 2026
32 checks passed
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.
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.

2 participants