Fix cross organization virtual mcp bug#2513
Open
0xcucumbersalad wants to merge 5 commits intodecocms:mainfrom
Open
Fix cross organization virtual mcp bug#25130xcucumbersalad wants to merge 5 commits intodecocms:mainfrom
0xcucumbersalad wants to merge 5 commits intodecocms:mainfrom
Conversation
Contributor
Release OptionsShould a new version be published when this PR is merged? React with an emoji to vote on the release type:
Current version: Deployment
|
Contributor
🧪 BenchmarkShould we run the Virtual MCP strategy benchmark for this PR? React with 👍 to run the benchmark.
Benchmark will run on the next push after you react. |
Contributor
There was a problem hiding this comment.
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/virtual-mcp.ts">
<violation number="1" location="apps/mesh/src/api/routes/virtual-mcp.ts:97">
P2: Authorization now compares the optional header-derived organizationId against ctx.organization?.id. When x-org-id/x-org-slug is omitted but a valid virtualMcpId is provided, organizationId is null and this check always 403s, breaking valid requests. Compare the resolved virtualMcp.organization_id to ctx.organization?.id (or guard the check) instead of requiring headers.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Here's a PR description you can use:
What is this contribution about?
Fixes a cross-organization authorization bypass in the virtual MCP/agent routes. Previously, a user could access agents belonging to a different organization by providing a foreign
organizationIdvia thex-org-idorx-org-slugheaders. This PR adds a check that verifies the resolvedorganizationIdmatches the authenticated user's organization (ctx.organization.id), returning a403 Forbiddenif they don't match.How to Test
/mcp/gateway/:virtualMcpIdor/mcp/virtual-mcp/:virtualMcpIdwith anx-org-idheader belonging to Organization B403 Forbiddenwith"Agent does not belong to your organization"x-org-idfor Organization A — request should succeed as beforeSummary by cubic
Fixes an auth bypass that let users access agents in other organizations on virtual MCP routes by spoofing x-org-id/x-org-slug. The server now validates virtualMcp.organization_id against ctx.organization.id and returns 403 (“Forbidden: Agent does not belong to your organization”) when they differ.
Written for commit 3aee08b. Summary will update on new commits.