Skip to content

fix(mcp): validate opaque credentials before OAuth sessions - #3068

Open
fahreddinozcan wants to merge 2 commits into
masterfrom
codex/ctx7-2021-mcp-oauth-auth-bypass
Open

fix(mcp): validate opaque credentials before OAuth sessions#3068
fahreddinozcan wants to merge 2 commits into
masterfrom
codex/ctx7-2021-mcp-oauth-auth-bypass

Conversation

@fahreddinozcan

@fahreddinozcan fahreddinozcan commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • reject bearer values that do not match a supported Context7 API-key or OAuth-token format
  • validate recognized opaque credentials through Context7's existing authenticated whoami endpoint before entering the MCP handler
  • fail closed before MCP initialization, tool listing, or tool calls when validation fails or is unavailable
  • use short bounded positive/negative caches keyed by credential hashes
  • preserve JWT validation, valid OAuth/API-key access, and anonymous access through /mcp

Security

Fixes the authentication bypass reported in Cobalt finding PT38659_11. Previously any bearer value that was not shaped like a JWT skipped validation and reached the MCP handler. Format recognition is only an early rejection gate: supported opaque formats still require explicit backend approval, so a well-shaped fake API key is rejected with 401 before MCP initialization.

Linear: CTX7-2021 (child of CTX7-2019)

Validation

  • pnpm run typecheck
  • pnpm run lint:check
  • pnpm test (6 files, 102 tests)
  • Prettier check on changed TypeScript files

@linear-code

linear-code Bot commented Aug 24, 2026

Copy link
Copy Markdown

CTX7-2021

@context7

context7 Bot commented Aug 24, 2026

Copy link
Copy Markdown

Docs7 preview for context7.com

Status Commit Updated (UTC)
✅ Ready (visit preview) d6918d7 2026-08-24 08:16

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