Skip to content

security(proxy): backport #51254 to stable/1.106.x - #51261

Merged
shrey-berri merged 2 commits into
stable/1.106.xfrom
litellm_backport_51254_stable_1_106_x
Nov 11, 2026
Merged

shrey-berri merged 2 commits into
stable/1.106.xfrom
litellm_backport_51254_stable_1_106_x

Conversation

@shrey-berri

@shrey-berri shrey-berri commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

clients could send requests with fields that conflicted with admin-set fields causing confusing or un-intended behavior. now, we "ban" those fields from requests by default for endpoints that don't need those values set from a client in a request. now, the client gets a 401, unless these fields are in metadata or admin explicitly opted in.

values written in admin-config format are always rejected.

TLDR

Problem this solves:

  • a request body field could conflict with a field the admin set on a deployment
  • the same conflict could come in through user_config deployments

How it solves it:

  • ban six common conflicting fields from the request body, unless an admin opted in
    • tenant_id, client_id, client_secret, azure_username, azure_password, azure_scope
  • refuse values in the admin-config format (os.environ/, oidc/) in credential fields and user_config
  • keep the names working where they are the API's own fields
    • client_secret on realtime transcription_sessions
    • client_id and client_secret on the MCP OAuth form and /introspect
    • all six as metadata tags

Intentional product change: a request body with any of the six fields on a model route or a pass-through route is refused unless an admin opted in, and a credential value in the os.environ/ or oidc/ format is refused outside deployment management routes. callers who used these as top-level tags can move them into metadata

on this line the pick adds the smallest copies of the MCP server route check and the user_config helpers #51254 uses, and writes the oidc/ prefix inline

User Flow

Before: a developer's request carries a field that clashes with the admin's deployment setup, and the call fails in a way that is hard to trace

  1. they send POST https://litellm-domain/v1/chat/completions for the Azure model with a tenant_id, client_id and client_secret in the body
  2. the proxy mixes those with the sign-in fields the admin set on the deployment
  3. they get a 500 from the Azure sign-in step, with no hint that their own fields caused it

After: the request is refused up front with a clear message, and the deployment keeps the setup the admin chose

  1. they send the same POST https://litellm-domain/v1/chat/completions with the same fields
  2. they get a 401 that names the field and says an admin has to opt in to allow it
  3. an admin who wants callers to set these turns on configurable_clientside_auth_params for that deployment

Relevant issues

Backport of #51254 to stable/1.106.x

Linear ticket

Resolves LIT-10665

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

every case ran against a real proxy started from the tree under test, with master key auth and no DB. a local stub on 127.0.0.1:18399 plays every upstream and logs each request it gets, so we can see exactly what left the proxy. PROXY_ENV_VALUE is a throwaway env var with a random value, used as the os.environ/ target in cases 1, 6 and 7. cases 1 and 6 make a real sign-in call to login.microsoftonline.com

before ran at 97a519b (the tip of stable/1.106.x) and after ran at ed842d6 (this PR's tip) in the same run, so both share one throwaway value, shown as <value> below

config (cases 1 to 5)
model_list:
  - model_name: azure-group
    litellm_params:
      model: azure/gpt-4o
      api_base: https://example-resource.openai.azure.com
      api_version: "2024-10-21"
      tenant_id: admin-tenant-literal
      client_id: admin-client-literal
      client_secret: admin-secret-literal
  - model_name: stub-chat
    litellm_params:
      model: openai/gpt-4o
      api_base: http://127.0.0.1:18399/v1
      api_key: sk-stub
  - model_name: gpt-4o-transcribe
    litellm_params:
      model: openai/gpt-4o-transcribe
      api_base: http://127.0.0.1:18399/v1
      api_key: sk-stub
general_settings:
  pass_through_endpoints:
    - path: /idp/token
      target: http://127.0.0.1:18399/oauth2/token
      auth: true

cases 6 to 8 use the same file with allow_client_side_credentials: true added under general_settings

stub upstream, proxy start, env
# stub.py, run as: python stub.py 18399 stub.log
import json, sys
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
LOG = sys.argv[2]
class H(BaseHTTPRequestHandler):
    def _handle(self):
        n = int(self.headers.get("content-length", 0) or 0)
        body = self.rfile.read(n).decode("utf-8", "replace")
        with open(LOG, "a") as f:
            f.write(json.dumps({"method": self.command, "path": self.path, "body": body,
                                "auth": self.headers.get("authorization") or self.headers.get("api-key")}) + "\n")
        out = json.dumps({"id": "stub", "object": "chat.completion", "created": 0, "model": "stub",
                          "choices": [{"index": 0, "message": {"role": "assistant", "content": "ok"}, "finish_reason": "stop"}],
                          "usage": {"prompt_tokens": 1, "completion_tokens": 1, "total_tokens": 2},
                          "client_secret": {"value": "ek_stub", "expires_at": 0}}).encode()
        self.send_response(200); self.send_header("content-type", "application/json"); self.send_header("content-length", str(len(out))); self.end_headers(); self.wfile.write(out)
    do_POST = _handle; do_GET = _handle
    def log_message(self, *a): pass
ThreadingHTTPServer(("127.0.0.1", int(sys.argv[1])), H).serve_forever()

env: LITELLM_MASTER_KEY (random), PROXY_ENV_VALUE (random), PYTHON_DOTENV_DISABLED=1, DISABLE_SCHEMA_UPDATE=true, DATABASE_URL unset

PYTHONPATH=<worktree>/enterprise:<worktree> python -c 'import sys, dotenv; dotenv.load_dotenv = lambda *a, **k: False; sys.argv = ["litellm", "--config", "config_a.yaml", "--port", "4911", "--host", "127.0.0.1"]; from litellm.proxy.proxy_cli import run_server; run_server()'

each case is one httpx call with Authorization: Bearer $LITELLM_MASTER_KEY and a 60s timeout. after each call we read the new lines in stub.log

Before (97a519b)

case 1: chat with tenant_id: "os.environ/..."

  1. POST /v1/chat/completions with {"model": "azure-group", "messages": [{"role": "user", "content": "hi"}], "tenant_id": "os.environ/PROXY_ENV_VALUE", "client_id": "caller-client", "client_secret": "caller-secret"}
  2. 500 litellm.APIError: AzureException APIError - Authentication failed: Unable to get authority configuration for https://login.microsoftonline.com/<value>. ...
  3. the error quotes the referenced value

case 2: configured pass-through with client_id in the query and body

  1. POST /idp/token?client_id=app-1 with {"grant_type": "client_credentials", "client_id": "app-1", "client_secret": "app-secret"}
  2. 200
  3. the stub got POST /oauth2/token?client_id=app-1 with body {"grant_type":"client_credentials"}, so the body's client_id and client_secret were already dropped before forwarding

case 3: realtime transcription session with OpenAI's client_secret expiry config

  1. POST /v1/realtime/transcription_sessions with {"model": "gpt-4o-transcribe", "client_secret": {"expires_at": {"anchor": "created_at", "seconds": 600}}}
  2. 200
  3. the stub got {"client_secret":{"expires_at":{"anchor":"created_at","seconds":600}}}

case 4: chat with a metadata tag in the os.environ/ format

  1. POST /v1/chat/completions with {"model": "stub-chat", "messages": [...], "metadata": {"tenant_id": "os.environ/HOME"}}
  2. 200, the stub got {"messages":[{"role":"user","content":"hi"}],"model":"gpt-4o"}

case 5: plain chat (control)

  1. POST /v1/chat/completions with {"model": "stub-chat", "messages": [{"role": "user", "content": "hi"}]}
  2. 200, the stub got {"messages":[{"role":"user","content":"hi"}],"model":"gpt-4o"}

case 6: case 1 with allow_client_side_credentials: true

  1. same request as case 1
  2. 500 with the same Unable to get authority configuration for https://login.microsoftonline.com/<value> message
  3. the error quotes the referenced value

case 7: user_config deployment with api_key: "os.environ/...", client-side credentials on

  1. POST /v1/chat/completions with {"model": "caller-model", "messages": [...], "user_config": {"model_list": [{"model_name": "caller-model", "litellm_params": {"model": "openai/gpt-4o", "api_base": "http://127.0.0.1:18399/caller/v1", "api_key": "os.environ/PROXY_ENV_VALUE"}}]}}
  2. 200
  3. the stub at /caller/v1/chat/completions got Bearer <value> as the api key header

case 8: user_config deployment with a literal key, client-side credentials on (control)

  1. same as case 7 with "api_key": "sk-caller-own"
  2. 200, the stub got the chat request with Bearer sk-caller-own

After (ed842d6)

case 1: chat with tenant_id: "os.environ/..."

  1. same request as before
  2. 401 Authentication Error, Rejected Request: tenant_id holds a secret reference, which only a deployment or credential a proxy admin configures can carry.
  3. no sign-in call is made

case 2: configured pass-through with client_id in the query and body

  1. same request as before
  2. 401 Authentication Error, Rejected Request: client_id is not allowed in request body. Clientside passthrough requires explicit admin opt-in via either general_settings.allow_client_side_credentials = true ...
  3. the stub got nothing. this is the intended product change above

case 3: realtime transcription session with OpenAI's client_secret expiry config

  1. same request as before
  2. 200
  3. the stub got the same session body as before, client_secret expiry config included

case 4: chat with a metadata tag in the os.environ/ format

  1. same request as before
  2. 200, the stub got {"messages":[{"role":"user","content":"hi"}],"model":"gpt-4o"}

case 5: plain chat (control)

  1. same request as before
  2. 200, the stub got {"messages":[{"role":"user","content":"hi"}],"model":"gpt-4o"}

case 6: case 1 with allow_client_side_credentials: true

  1. same request as case 1
  2. 401 tenant_id holds a secret reference, which only a deployment or credential a proxy admin configures can carry.
  3. no sign-in call is made

case 7: user_config deployment with api_key: "os.environ/...", client-side credentials on

  1. same request as before
  2. 401 Authentication Error, Rejected Request: api_key holds a secret reference, which only a deployment or credential a proxy admin configures can carry.
  3. the stub got nothing

case 8: user_config deployment with a literal key, client-side credentials on (control)

  1. same request as before
  2. 200, the stub got the chat request with Bearer sk-caller-own

unit tests: tests/unit/proxy/auth/test_auth_utils.py and tests/unit/proxy/test_credential_slot_registry.py, 618 passed at ed842d6. the 76 new rejection cases fail on 97a519b

Type

🐛 Bug Fix

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

…deployment fields

Six fields that also configure Azure sign-in on a deployment (tenant_id, client_id, client_secret, azure_username, azure_password, azure_scope) could be set in a request body, where they conflicted with the values an admin set on the deployment

They are now refused at the body root, in extra_body and in litellm_embedding_config unless an admin opted in with allow_client_side_credentials or configurable_clientside_auth_params. Credential fields and user_config deployments also refuse values in the os.environ/ and oidc/ format, which only admin config uses. Deployment management routes are unchanged

Routes where these names are the API's own fields keep accepting them. That covers client_secret on the realtime transcription_sessions routes, client_id and client_secret on the MCP server OAuth form and on /introspect, and all six as metadata tags

Co-authored-by: Oliver Jensen <oliver@berri.ai>

(cherry picked from commit 6ba6b04)
…removed

client_secret and azure_password are no longer accepted in a request body by default, so the registry's list of credential params a client may send no longer includes them

(cherry picked from commit 2b7e860)
@shrey-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@shrey-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@shrey-berri

Copy link
Copy Markdown
Contributor Author

/devin review

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Starting Devin Review.

Devin Review

@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: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@greptile-apps

greptile-apps Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The reviewed changes appear safe to merge

Summary

This backport rejects six conflicting Azure credential fields unless an admin opts in. It also rejects secret references in credential fields and supported user_config entries, while preserving route-owned OAuth fields and metadata tags

shrey-berri explicitly identifies the broader rejection of top-level fields on model and pass-through routes as intentional. Callers using those fields as tags must move them into metadata

No actionable issue was established from the reviewed changes

  • Ordinary requests cannot override Azure Entra sign-in fields without admin approval.
  • Credential fields reject admin-config secret references from ordinary requests.

Reviews (1) · Last reviewed commit: "test(proxy): drop the two request body c..." · Reviewed by Greptile

@cursor cursor 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit ed842d6. Configure here.

@shrey-berri
shrey-berri marked this pull request as ready for review November 11, 2026 23:12
@shrey-berri
shrey-berri requested a review from a team November 11, 2026 23:12
@veria-ai

veria-ai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

No security issues were found in this pull request.

Reviews

@shrey-berri shrey-berri changed the title fix(proxy): backport #51254 to stable/1.106.x security(proxy): backport #51254 to stable/1.106.x Nov 11, 2026
@shrey-berri
shrey-berri merged commit e6b3260 into stable/1.106.x Nov 11, 2026
13 of 16 checks passed
@shrey-berri
shrey-berri deleted the litellm_backport_51254_stable_1_106_x branch November 11, 2026 23:39
pocharlies pushed a commit to pocharlies-org/litellm that referenced this pull request Nov 12, 2026
Prepares stable/1.106.x for the v1.106.9 patch, which ships BerriAI#51261 and BerriAI#49888.
litellm-enterprise and litellm-proxy-extras have no changes since v1.106.8, so only the root package moves.

This branch was successfully deployed

No deployments
e2e-changed — ed842d6a Deployed Nov 11, 2026 by shrey-berri via oauth #6109
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants