Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
6 changes: 5 additions & 1 deletion litellm-proxy-extras/litellm_proxy_extras/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,15 @@ model LiteLLM_MCPServerTable {
is_byok Boolean @default(false)
byok_description String[] @default([])
byok_api_key_help_url String?
approval_status String @default("approved")
source_url String?
// BYOM submission lifecycle
approval_status String? @default("active")
submitted_by String?
submitted_at DateTime?
reviewed_at DateTime?
review_notes String?

@@index([approval_status])
}

// Per-user BYOK credentials for MCP servers
Expand Down
12 changes: 3 additions & 9 deletions litellm/proxy/management_endpoints/mcp_management_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

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.

P2 No resource guard after removing admin-only restriction

Removing the PROXY_ADMIN check 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:

  1. Resource exhaustion — flood the in-memory session cache with thousands of short-lived entries until the proxy OOMs.
  2. SSRF probe — point the session server URL at an internal host (e.g. 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)

Copy link
Copy Markdown
Author

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.

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.

P1 Credential inheritance by non-admin callers

_inherit_credentials_from_existing_server runs unconditionally here and will copy sensitive credentials (OAuth client_secret, auth_value, AWS access/secret key, etc.) from any permanently-registered server whose server_id matches the caller-supplied value.

Before this PR only PROXY_ADMIN could reach this code path, so credential access was already gated. Now any authenticated user can pass an arbitrary server_id they know (or guess) and cause the endpoint to pick up that server's stored secrets. The credentials are redacted from the response (_redact_mcp_credentials(temp_record)) but the session server is cached in _temporary_mcp_servers with the full credentials intact, and subsequent tool-call / OAuth-flow requests that use the temp server_id will execute with those inherited secrets.

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 inheritance

Alternatively, restrict _inherit_credentials_from_existing_server to only run when the caller supplies no server_id (forcing non-admins to always specify a fresh ID), which prevents piggybacking on an existing server's stored secrets.

Rule Used: What: Fail any PR which may contains a security in... (source)

temp_record = _build_temporary_mcp_server_record(
Expand Down
9 changes: 9 additions & 0 deletions schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,15 @@ model LiteLLM_MCPServerTable {
is_byok Boolean @default(false)
byok_description String[] @default([])
byok_api_key_help_url String?
source_url String?
// BYOM submission lifecycle
approval_status String? @default("active")
submitted_by String?
submitted_at DateTime?
reviewed_at DateTime?
review_notes String?

@@index([approval_status])
}

// Per-user BYOK credentials for MCP servers
Expand Down
Loading