Fix confused deputy attack via consent binding cookie (#3201)

* Add consent binding cookie to prevent confused deputy attacks (GHSA-rww4-4w9c-7733)

The OAuthProxy's consent page verified user intent but didn't bind the
consenting browser to the IdP callback. An attacker could intercept the
upstream authorization URL after consent and send it to a victim, whose
browser would complete the flow without having the consent cookie.

This adds a signed consent binding cookie set during consent approval
(both manual and auto-approve paths) and verified in the IdP callback
handler. A different browser won't have this cookie and gets a 403.

* Use startswith for URL assertion in consent binding test

* Store consent bindings as per-transaction map to support parallel flows

* Only accept __Host- consent binding cookie on HTTPS

* chore: Update SDK documentation

---------

Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com>
This commit is contained in:
Jeremiah Lowin 2026-02-17 10:24:07 -05:00 committed by GitHub
commit 016b9f90e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 415 additions and 18 deletions

View file

@ -52,7 +52,7 @@ max_lines = 1009
[[rules]]
path = "tests/server/auth/test_oauth_consent_flow.py"
max_lines = 1056
max_lines = 1274
[[rules]]
path = "src/fastmcp/server/server.py"
@ -76,7 +76,7 @@ max_lines = 1584
[[rules]]
path = "src/fastmcp/server/auth/oauth_proxy/proxy.py"
max_lines = 1740
max_lines = 1796
[[rules]]
path = "tests/server/test_dependencies.py"