Skip to content

Security: OAuth callback does not validate state parameter#1189

Open
tuanaiseo wants to merge 2 commits intomodelcontextprotocol:mainfrom
tuanaiseo:contribai/fix/security/oauth-callback-does-not-validate-state-p
Open

Security: OAuth callback does not validate state parameter#1189
tuanaiseo wants to merge 2 commits intomodelcontextprotocol:mainfrom
tuanaiseo:contribai/fix/security/oauth-callback-does-not-validate-state-p

Conversation

@tuanaiseo
Copy link
Copy Markdown

Problem

The OAuth callback flow accepts an authorization code from the URL and proceeds with token exchange, but there is no validation of the OAuth state parameter to bind the response to the original auth request. This can enable login CSRF/session mix-up attacks where an attacker injects a valid code for a different authorization context.

Severity: high
File: client/src/components/OAuthCallback.tsx

Solution

Store a cryptographically-random state value before redirecting to the authorization server, include it in the auth request, parse state from callback parameters, and reject the callback if it does not exactly match the stored value. Also clear the stored state after successful validation.

Changes

  • client/src/components/OAuthCallback.tsx (modified)
  • client/src/components/AppRenderer.tsx (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

The OAuth callback flow accepts an authorization `code` from the URL and proceeds with token exchange, but there is no validation of the OAuth `state` parameter to bind the response to the original auth request. This can enable login CSRF/session mix-up attacks where an attacker injects a valid code for a different authorization context.

Affected files: OAuthCallback.tsx, AppRenderer.tsx

Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
The OAuth callback flow accepts an authorization `code` from the URL and proceeds with token exchange, but there is no validation of the OAuth `state` parameter to bind the response to the original auth request. This can enable login CSRF/session mix-up attacks where an attacker injects a valid code for a different authorization context.

Affected files: OAuthCallback.tsx, AppRenderer.tsx

Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
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.

1 participant