Skip to content

test(auth): verify org-less API key rejection on OAuth token routes#3039

Open
0xcucumbersalad wants to merge 1 commit intodecocms:mainfrom
0xcucumbersalad:fix/authz-vuln-08-orgless-apikey-test
Open

test(auth): verify org-less API key rejection on OAuth token routes#3039
0xcucumbersalad wants to merge 1 commit intodecocms:mainfrom
0xcucumbersalad:fix/authz-vuln-08-orgless-apikey-test

Conversation

@0xcucumbersalad
Copy link
Copy Markdown
Contributor

@0xcucumbersalad 0xcucumbersalad commented Apr 7, 2026

Summary

  • Adds test coverage for AUTHZ-VULN-08 (cross-tenant OAuth token injection via org-less API key)
  • The runtime fix (org context guard returning 403) was already merged in the prior PR — this PR adds regression tests proving the guard works for all three OAuth token endpoints (POST, DELETE, GET status)
  • Tests verify that requests with organization: undefined (simulating an org-less API key) are rejected with 403 before findById is ever called

Test plan

  • bun test apps/mesh/src/api/routes/downstream-token.test.ts — 6/6 pass (3 existing + 3 new)
  • bun run lint — passes
  • bun run fmt — passes

🤖 Generated with Claude Code


Summary by cubic

Add regression tests to ensure org-less API keys are rejected (403) across all OAuth token routes (POST, DELETE, GET status). Confirms the org-context guard for AUTHZ-VULN-08 and prevents cross-tenant OAuth token injection.

Written for commit 169a2ca. Summary will update on new commits.

…outes

Verifies that POST, DELETE, and GET status endpoints return 403 when
the request lacks organization context (e.g., org-less API keys),
preventing cross-tenant OAuth token injection (AUTHZ-VULN-08).

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

github-actions bot commented Apr 7, 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 7, 2026

Release Options

Suggested: Patch (2.243.1) — based on test: prefix

React with an emoji to override the release type:

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

Current version: 2.243.0

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.

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/mesh/src/api/routes/downstream-token.test.ts">

<violation number="1" location="apps/mesh/src/api/routes/downstream-token.test.ts:118">
P2: The new regression tests never assert `findById` is not called, so they don’t verify the intended “reject before lookup” security behavior.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

auth: { user: { id: "user_1" }, apiKey: { userId: "user_1" } },
storage: {
connections: {
findById: mock(async () => ({ id: "conn_1" })),
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Apr 7, 2026

Choose a reason for hiding this comment

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

P2: The new regression tests never assert findById is not called, so they don’t verify the intended “reject before lookup” security behavior.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/mesh/src/api/routes/downstream-token.test.ts, line 118:

<comment>The new regression tests never assert `findById` is not called, so they don’t verify the intended “reject before lookup” security behavior.</comment>

<file context>
@@ -105,4 +105,62 @@ describe("Downstream Token Routes", () => {
+        auth: { user: { id: "user_1" }, apiKey: { userId: "user_1" } },
+        storage: {
+          connections: {
+            findById: mock(async () => ({ id: "conn_1" })),
+          },
+        },
</file context>
Fix with Cubic

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