Repository navigation
fix: resolve MCP server creation failures (schema drift, oauth2_flow mapping, session permissions) #24941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: resolve MCP server creation failures (schema drift, oauth2_flow mapping, session permissions) #24941
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| -- Restore BYOM approval workflow columns that were accidentally dropped by | ||
| -- 20260311180521_schema_sync. That migration was auto-generated because the | ||
| -- root schema.prisma was not updated when PR #23205 added the submission | ||
| -- workflow. This migration re-adds the columns and index. | ||
|
|
||
| ALTER TABLE "LiteLLM_MCPServerTable" | ||
| ADD COLUMN IF NOT EXISTS "source_url" TEXT, | ||
| ADD COLUMN IF NOT EXISTS "approval_status" TEXT DEFAULT 'active', | ||
| ADD COLUMN IF NOT EXISTS "submitted_by" TEXT, | ||
| ADD COLUMN IF NOT EXISTS "submitted_at" TIMESTAMP(3), | ||
| ADD COLUMN IF NOT EXISTS "reviewed_at" TIMESTAMP(3), | ||
| ADD COLUMN IF NOT EXISTS "review_notes" TEXT; | ||
|
|
||
| -- Back-fill existing rows: anything already in the table is implicitly active. | ||
| UPDATE "LiteLLM_MCPServerTable" | ||
| SET "approval_status" = 'active' | ||
| WHERE "approval_status" IS NULL; | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX IF NOT EXISTS "LiteLLM_MCPServerTable_approval_status_idx" | ||
| ON "LiteLLM_MCPServerTable"("approval_status"); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1288,15 +1288,9 @@ async def add_session_mcp_server( | |
| # Validate and normalize payload fields (alias/server name rules) | ||
| validate_and_normalize_mcp_server_payload(payload) | ||
|
|
||
| # Restrict to proxy admins similar to the persistent create endpoint | ||
| if LitellmUserRoles.PROXY_ADMIN != user_api_key_dict.user_role: | ||
| raise HTTPException( | ||
| status_code=status.HTTP_403_FORBIDDEN, | ||
| detail={ | ||
| "error": "User does not have permission to create temporary mcp servers. You can only create temporary mcp servers if you are a PROXY_ADMIN." | ||
| }, | ||
| ) | ||
|
|
||
| # Session servers are ephemeral (in-memory, ~5 min TTL, no DB write) so | ||
| # any authenticated user may create one. This lets non-admin users run | ||
| # the OAuth auth-test before submitting a server for review. | ||
| created_by = user_api_key_dict.user_id or LITELLM_PROXY_ADMIN_NAME | ||
| payload_with_credentials = _inherit_credentials_from_existing_server(payload) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Before this PR only A minimal fix would be to skip inheritance if the caller is not an admin: if LitellmUserRoles.PROXY_ADMIN == user_api_key_dict.user_role:
payload = _inherit_credentials_from_existing_server(payload)
# else: non-admin must supply explicit credentials; no inheritanceAlternatively, restrict Rule Used: What: Fail any PR which may contains a security in... (source) |
||
| temp_record = _build_temporary_mcp_server_record( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the
PROXY_ADMINcheck means any authenticated user can now call this endpoint repeatedly. Because the session cache likely has no per-user quota, a malicious (but valid) key holder could:http://169.254.169.254/) and inspect error messages that leak reachability, since session servers attempt to connect to the given URL when the OAuth flow is exercised.Neither risk existed before, because only admins (who already have full access) could reach this path. Consider adding a lightweight per-user rate limit or at least an explicit URL allow-list / block-list before broadening this to all authenticated callers.
Rule Used: What: Fail any PR which may contains a security in... (source)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a pre-existing concern at the API level, not specific to session servers. Any authenticated key can already flood numerous other endpoints. Neither issue is introduced by this diff in isolation, and reverting the restriction breaks the intended OAuth-test-before-submit workflow. The SSRF concern is real but belongs in validate_and_normalize_mcp_server_payload as a URL allowlist/blocklist, not as a role gate.