Skip to content

fix(mcp-server): restrict OAuth redirects and CORS#139

Open
dhairyashiil wants to merge 4 commits into
calcom:mainfrom
dhairyashiil:codex/security-mcp-hardening
Open

fix(mcp-server): restrict OAuth redirects and CORS#139
dhairyashiil wants to merge 4 commits into
calcom:mainfrom
dhairyashiil:codex/security-mcp-hardening

Conversation

@dhairyashiil

Copy link
Copy Markdown
Member

Summary

Hardens MCP HTTP/OAuth defaults by rejecting unallowlisted external dynamic-client redirect URIs, keeping loopback redirects for local clients, and resolving CORS to a concrete configured/server origin instead of permissive defaults.

Reviewer notes

  • Production should set ALLOWED_REDIRECT_HOSTS for every legitimate external OAuth callback host.
  • ALLOW_OPEN_REDIRECT_REGISTRATION=true is documented as unsafe/dev-only and should not be enabled in hosted production.
  • Production should set CORS_ORIGIN if browser clients call MCP from a different origin than MCP_SERVER_URL.
  • Please review self-hosted expectations carefully: this PR intentionally fails closed for external redirect hosts unless they are configured.

Validation

  • bun --filter @calcom/mcp-server test -- src/auth/oauth-handlers.test.ts src/utils/http-security.test.ts
  • bun --filter @calcom/mcp-server test
  • bun --filter @calcom/mcp-server typecheck
  • bun --filter @calcom/mcp-server build
  • git diff --check HEAD~1..HEAD

@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

@dhairyashiil is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@dhairyashiil dhairyashiil marked this pull request as ready for review July 2, 2026 21:07
@dhairyashiil dhairyashiil enabled auto-merge (squash) July 2, 2026 21:07

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

Open in Devin Review

Comment thread apps/mcp-server/src/http-server.ts

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 10 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread apps/mcp-server/src/http-server.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant