Skip to content

Thread VirtualMCPServer name into Cedar authz middleware - #5448

Merged
jhrozek merged 1 commit into
mainfrom
worktree-mvpc-cedar-fix
Jun 3, 2026
Merged

Thread VirtualMCPServer name into Cedar authz middleware#5448
jhrozek merged 1 commit into
mainfrom
worktree-mvpc-cedar-fix

Conversation

@jhrozek

Copy link
Copy Markdown
Contributor

Summary

  • Cedar authorization policies reference the actual VirtualMCPServer name as the resource entity (e.g. MCP::"my-vmcp"). The factory hard-coded the string "vmcp" when calling authz.CreateMiddlewareFromConfig, so resource entities never matched and Cedar's default-deny fired on every request — 403 for all principals regardless of policy.
  • Fix by adding a serverName parameter to NewIncomingAuthMiddleware and newCedarAuthzMiddleware, passing vmcpCfg.Name at the serve.go call site.
  • Add an empty-string guard in newCedarAuthzMiddleware so a misconfigured (empty) server name fails loudly at startup rather than silently mismatching all resource-scoped policies.

Fixes#5428

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Test plan

  • Added regression test TestNewIncomingAuthMiddleware_ServerNameThreaded that compiles a Cedar permit policy scoped to resource in MCP::"my-production-vmcp", calls NewIncomingAuthMiddleware with serverName = "my-production-vmcp", and asserts the request is permitted (200).
  • Negative sub-test with serverName = "wrong-server" asserts 403 — verifies that the server name is actually threaded through to Cedar evaluation, not hardcoded.
  • task test passes on the affected package.

Does this introduce a user-facing change?

Yes: VirtualMCPServer Cedar authorization now correctly evaluates resource-scoped policies using the server's actual name. Previously all Cedar-gated requests returned 403 when policies used resource in MCP::"<name>" scoping.

Generated with Claude Code

Cedar authorization policies compiled by the operator reference the
actual VirtualMCPServer name as the resource entity (e.g. MCP::"my-vmcp").
The factory hard-coded the string "vmcp" when calling
authz.CreateMiddlewareFromConfig, so the resource entity never matched
and Cedar's default-deny fired on every request — 403 for all principals
regardless of policy.
Fix by adding a serverName parameter to NewIncomingAuthMiddleware and
newCedarAuthzMiddleware, and passing vmcpCfg.Name at the serve.go call
site. Adds a regression test that scopes a Cedar permit policy to a
specific resource name and asserts it is honoured.
Fixes#5428
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actionsgithub-actionsBot added the size/S Small PR: 100-299 lines changed label Jun 3, 2026
@codecov

codecovBot commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.85%. Comparing base (a785995) to head (a57f278).

Files with missing linesPatch %Lines
pkg/vmcp/auth/factory/incoming.go60.00%1 Missing and 1 partial ⚠️
pkg/vmcp/cli/serve.go0.00%1 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #5448 +/- ##
==========================================
- Coverage 68.85% 68.85% -0.01% 
==========================================
Files 634 634 Lines 64437 64439 +2 ==========================================
- Hits 44371 44369 -2 - Misses 16789 16792 +3 - Partials 3277 3278 +1 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jhrozek
jhrozek merged commit 4d3b392 into mainJun 3, 2026
78 of 79 checks passed
@jhrozek
jhrozek deleted the worktree-mvpc-cedar-fix branch June 3, 2026 20:57
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/SSmall PR: 100-299 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VirtualMCPServer Cedar authz middleware uses hard-coded "vmcp" as resource name instead of the actual server name

5 participants

@jhrozek@tgrunnagle@jerm-dro@ChrisJBurns@reyortiz3