Repository navigation
security(proxy): backport #51254 to stable/1.106.x - #51261
Conversation
…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)
|
bugbot run |
|
/devin review |
[High impact] The reviewed changes appear safe to merge SummaryThis backport rejects six conflicting Azure credential fields unless an admin opts in. It also rejects secret references in credential fields and supported
No actionable issue was established from the reviewed changes
Reviews (1) · Last reviewed commit: "test(proxy): drop the two request body c..." · Reviewed by Greptile |
There was a problem hiding this comment.
✅ 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.
PR overviewNo security issues were found in this pull request. Reviews
|
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.
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
metadataor admin explicitly opted in.values written in admin-config format are always rejected.
TLDR
Problem this solves:
user_configdeploymentsHow it solves it:
tenant_id,client_id,client_secret,azure_username,azure_password,azure_scopeos.environ/,oidc/) in credential fields anduser_configclient_secreton realtimetranscription_sessionsclient_idandclient_secreton the MCP OAuth form and/introspectIntentional 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/oroidc/format is refused outside deployment management routes. callers who used these as top-level tags can move them intometadataon this line the pick adds the smallest copies of the MCP server route check and the
user_confighelpers #51254 uses, and writes theoidc/prefix inlineUser 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
tenant_id,client_idandclient_secretin the bodyAfter: the request is refused up front with a clear message, and the deployment keeps the setup the admin chose
configurable_clientside_auth_paramsfor that deploymentRelevant 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
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@greptileaito 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_VALUEis a throwaway env var with a random value, used as theos.environ/target in cases 1, 6 and 7. cases 1 and 6 make a real sign-in call to login.microsoftonline.combefore 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>belowconfig (cases 1 to 5)
cases 6 to 8 use the same file with
allow_client_side_credentials: trueadded undergeneral_settingsstub upstream, proxy start, env
env:
LITELLM_MASTER_KEY(random),PROXY_ENV_VALUE(random),PYTHON_DOTENV_DISABLED=1,DISABLE_SCHEMA_UPDATE=true,DATABASE_URLunseteach case is one httpx call with
Authorization: Bearer $LITELLM_MASTER_KEYand a 60s timeout. after each call we read the new lines instub.logBefore (97a519b)
case 1: chat with
tenant_id: "os.environ/..."POST /v1/chat/completionswith{"model": "azure-group", "messages": [{"role": "user", "content": "hi"}], "tenant_id": "os.environ/PROXY_ENV_VALUE", "client_id": "caller-client", "client_secret": "caller-secret"}litellm.APIError: AzureException APIError - Authentication failed: Unable to get authority configuration for https://login.microsoftonline.com/<value>. ...case 2: configured pass-through with
client_idin the query and bodyPOST /idp/token?client_id=app-1with{"grant_type": "client_credentials", "client_id": "app-1", "client_secret": "app-secret"}POST /oauth2/token?client_id=app-1with body{"grant_type":"client_credentials"}, so the body'sclient_idandclient_secretwere already dropped before forwardingcase 3: realtime transcription session with OpenAI's
client_secretexpiry configPOST /v1/realtime/transcription_sessionswith{"model": "gpt-4o-transcribe", "client_secret": {"expires_at": {"anchor": "created_at", "seconds": 600}}}{"client_secret":{"expires_at":{"anchor":"created_at","seconds":600}}}case 4: chat with a metadata tag in the
os.environ/formatPOST /v1/chat/completionswith{"model": "stub-chat", "messages": [...], "metadata": {"tenant_id": "os.environ/HOME"}}{"messages":[{"role":"user","content":"hi"}],"model":"gpt-4o"}case 5: plain chat (control)
POST /v1/chat/completionswith{"model": "stub-chat", "messages": [{"role": "user", "content": "hi"}]}{"messages":[{"role":"user","content":"hi"}],"model":"gpt-4o"}case 6: case 1 with
allow_client_side_credentials: trueUnable to get authority configuration for https://login.microsoftonline.com/<value>messagecase 7:
user_configdeployment withapi_key: "os.environ/...", client-side credentials onPOST /v1/chat/completionswith{"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"}}]}}/caller/v1/chat/completionsgotBearer <value>as the api key headercase 8:
user_configdeployment with a literal key, client-side credentials on (control)"api_key": "sk-caller-own"Bearer sk-caller-ownAfter (ed842d6)
case 1: chat with
tenant_id: "os.environ/..."Authentication Error, Rejected Request: tenant_id holds a secret reference, which only a deployment or credential a proxy admin configures can carry.case 2: configured pass-through with
client_idin the query and bodyAuthentication 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 ...case 3: realtime transcription session with OpenAI's
client_secretexpiry configclient_secretexpiry config includedcase 4: chat with a metadata tag in the
os.environ/format{"messages":[{"role":"user","content":"hi"}],"model":"gpt-4o"}case 5: plain chat (control)
{"messages":[{"role":"user","content":"hi"}],"model":"gpt-4o"}case 6: case 1 with
allow_client_side_credentials: truetenant_id holds a secret reference, which only a deployment or credential a proxy admin configures can carry.case 7:
user_configdeployment withapi_key: "os.environ/...", client-side credentials onAuthentication Error, Rejected Request: api_key holds a secret reference, which only a deployment or credential a proxy admin configures can carry.case 8:
user_configdeployment with a literal key, client-side credentials on (control)Bearer sk-caller-ownunit tests:
tests/unit/proxy/auth/test_auth_utils.pyandtests/unit/proxy/test_credential_slot_registry.py, 618 passed at ed842d6. the 76 new rejection cases fail on 97a519bType
🐛 Bug Fix
Final Attestation