Skip to content

fix(auth): prevent cross-tenant connection enumeration via OAuth metadata endpoints#3060

Open
0xcucumbersalad wants to merge 1 commit intodecocms:mainfrom
0xcucumbersalad:fix/authz-vuln-06-unauth-connection-enumeration
Open

fix(auth): prevent cross-tenant connection enumeration via OAuth metadata endpoints#3060
0xcucumbersalad wants to merge 1 commit intodecocms:mainfrom
0xcucumbersalad:fix/authz-vuln-06-unauth-connection-enumeration

Conversation

@0xcucumbersalad
Copy link
Copy Markdown
Contributor

@0xcucumbersalad 0xcucumbersalad commented Apr 8, 2026

Summary

  • AUTHZ-VULN-06: OAuth discovery endpoints (/.well-known/oauth-protected-resource/mcp/:connectionId) performed unscoped findById and returned distinct 404/502 status codes, creating an unauthenticated connection existence oracle
  • Passes ctx.organization?.id to findById so connection lookups are org-scoped when auth context is available
  • Normalizes error responses: both "connection not found" and "upstream fetch failed" now return identical 404 responses, eliminating the enumeration oracle
  • Same fix applied to the authorization server metadata endpoint (/.well-known/oauth-authorization-server/oauth-proxy/:connectionId)

Test plan

  • bun test apps/mesh/src/api/routes/oauth-proxy.test.ts — 26/26 pass
  • Updated existing "returns 502 when origin fetch fails" test to verify new 404 behavior
  • Added new test: "returns same 404 for non-existent and unreachable connections (no enumeration oracle)"
  • bun run lint — passes
  • bun run fmt — passes

🤖 Generated with Claude Code


Summary by cubic

Prevents cross-tenant connection enumeration by scoping OAuth discovery lookups to the organization and normalizing errors to a single 404 response.

  • Bug Fixes
    • Pass ctx.organization?.id to findById so connection lookups are org-scoped.
    • Return 404 for both “connection not found” and upstream fetch failures to avoid existence oracles.
    • Apply the same behavior to both endpoints: /.well-known/oauth-protected-resource/mcp/:connectionId and /.well-known/oauth-authorization-server/oauth-proxy/:connectionId.
    • Update tests to assert unified 404 responses and prevent enumeration.

Written for commit 60911bd. Summary will update on new commits.

…data endpoints

The OAuth discovery endpoints (/.well-known/oauth-protected-resource)
called findById without org scoping, and returned distinct status codes
(404 vs 502) that revealed whether a connection existed. Fixes both:
- Passes organization ID to findById when auth context is available
- Normalizes error responses to 404 for both "not found" and "proxy
  failed" to eliminate the enumeration oracle

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

🧪 Benchmark

Should we run the Virtual MCP strategy benchmark for this PR?

React with 👍 to run the benchmark.

Reaction Action
👍 Run quick benchmark (10 & 128 tools)

Benchmark will run on the next push after you react.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

Release Options

Suggested: Patch (2.248.8) — based on fix: prefix

React with an emoji to override the release type:

Reaction Type Next Version
👍 Prerelease 2.248.8-alpha.1
🎉 Patch 2.248.8
❤️ Minor 2.249.0
🚀 Major 3.0.0

Current version: 2.248.7

Note: If multiple reactions exist, the smallest bump wins. If no reactions, the suggested bump is used (default: patch).

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

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