Skip to content

Bind Discord token verification to configured client_id#3405

Merged
jlowin merged 1 commit intomainfrom
codex/fix-discord-token-verifier-vulnerability
Mar 6, 2026
Merged

Bind Discord token verification to configured client_id#3405
jlowin merged 1 commit intomainfrom
codex/fix-discord-token-verifier-vulnerability

Conversation

@jlowin
Copy link
Copy Markdown
Member

@jlowin jlowin commented Mar 6, 2026

Motivation

  • Discord token verification previously accepted any access token that passed /api/oauth2/@me and had the required scopes regardless of which Discord application minted the token, breaking audience/client binding and enabling cross-app authentication bypass.

Description

  • Add an expected_client_id parameter to DiscordTokenVerifier and store it on the verifier.
  • During verify_token, compare the application.id returned by Discord with expected_client_id and reject the token if they do not match.
  • Thread the provider client_id into DiscordTokenVerifier from DiscordProvider so provider-based usage enforces the client/audience binding automatically.
  • Update tests to assert the verifier is bound to the provider client_id, add a test that rejects tokens from a different Discord application, and update an existing http-client test to satisfy the new verifier signature.

Testing

  • Ran uv sync successfully.
  • Ran the full test suite with uv run pytest -n auto; the run surfaced unrelated, pre-existing timeouts/failures in this environment (11 failed, 4679 passed, 1 error) so the repository-wide run is not green here but failures are not related to the changes.
  • Ran targeted tests uv run pytest tests/server/auth/providers/test_discord.py tests/server/auth/providers/test_http_client.py -n auto and both passed (26 passed).
  • Ran static hooks uv run prek run --all-files which failed to initialize external prettier hook due to network access to pre-commit mirror (environment restriction), not due to code linting errors.

Codex Task

🤖 Generated with GPT-5.2-Codex
@marvin-context-protocol marvin-context-protocol Bot added bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. auth Related to authentication (Bearer, JWT, OAuth, WorkOS) for client or server. high-priority labels Mar 6, 2026
@jlowin jlowin merged commit 216f43d into main Mar 6, 2026
8 checks passed
@jlowin jlowin deleted the codex/fix-discord-token-verifier-vulnerability branch March 6, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark auth Related to authentication (Bearer, JWT, OAuth, WorkOS) for client or server. bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. codex high-priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant