Repository navigation
fix(auth): allow trailing slashes on MCP CSRF exemptions - #7533
Conversation
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — CSRF trailing-slash normalization fix.
This PR adds trailing-slash normalization to the CSRF exemption check (server/src/middleware/csrf.ts:15) so that /mcp/ and //mcp/ reach their bearer/RFC-9421 authenticators instead of being 403'd by the double-submit-cookie middleware. The change only matches alternate spellings of already-exempt handlers — no cookie-authed route is newly exempted — and near-misses (/mcp//, /mcp/extra) remain protected, with test coverage asserting 403.
Server-middleware-only change; no protocol surface (static/schemas/source/, docs/reference/, dist/**) touched, so no changeset is required. No Critical/High/Medium findings.
Gate checks: no no-auto-approve team match; gated_paths is false; high_risk is false; no prior decision. review_decision is REVIEW_REQUIRED but the gated-paths gate (row 2) only applies when gated_paths is true — it is false here. No decision-table rows 1–8 fire, so this falls through to row 9: approve.
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — clean CSRF fix for MCP route trailing-slash normalization.
This PR narrowly normalizes one optional trailing slash before the bearer/RFC 9421-authed MCP exact and per-tenant exemptions so /mcp/ reaches its bearer authenticator instead of returning a 403. Verified:
- Normalization is confined to MCP route families; byte-exact matching is preserved for
/token,/register, etc. - Fail-closed behavior holds for
/mcp//and appended paths. - The fix is covered by an end-to-end test wiring the real csrfProtection to the real router.
- No changeset required — this is a server-only operational change, not a change to the published protocol surface (
static/schemas/source/**, normative docs, dist artifacts).
No Critical/High/Medium findings. This is a server-only change (server/**) with no schema/docs/spec surface touched, so schema↔docs coherence, changeset scope, oneOf discriminator, artifact immutability, and 3.1.x-patch gates do not apply. gated_paths is false; high_risk is false; no no-auto-approve team match. No blocking or escalation triggers fire — falls through to row 9.
Summary
/mcp/reach bearer authentication instead of returning403 cookie_expiredProduction evidence
POST https://test-agent.adcontextprotocol.org/mcp/without credentials currently returns403 CSRF validation failedbefore the training-agent authenticator can emit its401 WWW-Authenticatechallenge. The documented CLI endpoint includes that trailing slash.The member OAuth surface at
https://agenticadvertising.org/mcpremains healthy through RFC 9728/RFC 8414 discovery, dynamic client registration, PKCE authorization construction, and redirect to WorkOS; this PR fixes the separate host-routed endpoint regression.Verification
npx vitest run server/tests/unit/csrf-middleware.test.ts --config server/vitest.config.ts(64 passed)npm run typecheckgit diff --checkNo changeset: operational server fix only.