(Security) - Prevent potential provider key exposure through URL-valued model destinations and fallbacks - #34189
Conversation
Greptile SummaryThis PR strengthens request validation and provider destination handling. The main changes are:
Confidence Score: 5/5This looks safe to merge.
|
| Filename | Overview |
|---|---|
| litellm/litellm_core_utils/url_utils.py | Adds shared parsing for plain, provider-prefixed, and comma-separated destination candidates. |
| litellm/proxy/auth/auth_utils.py | Adds bounded fallback traversal and validates banned parameters and URL destinations for each target. |
| litellm/proxy/auth/user_api_key_auth.py | Reuses shared fallback traversal when enforcing model access. |
| litellm/proxy/litellm_pre_call_utils.py | Applies destination validation to every candidate extracted from model and file identifiers. |
| litellm/llms/huggingface/embedding/handler.py | Uses an explicit HTTP scheme prefix when selecting the embedding destination. |
| litellm/llms/oobabooga/chat/oobabooga.py | Uses explicit HTTP scheme prefixes for completion and embedding destinations. |
| tests/test_litellm/proxy/auth/test_auth_utils.py | Covers nested fallback validation, depth rejection, URL targets, and the added credential alias. |
| tests/test_litellm/proxy/auth/test_router_override_fallback_auth.py | Covers fallback model authorization across request surfaces and nested fallback shapes. |
| tests/test_litellm/proxy/test_provider_url_destination_guard.py | Covers prefixed, comma-separated, uppercase, allowlisted, and ordinary destination values. |
Reviews (7): Last reviewed commit: "chore(proxy): clean up request parameter..." | Re-trigger Greptile
Greptile SummaryThis PR hardens proxy request validation and provider endpoint selection. The main changes are:
Confidence Score: 5/5This looks safe to merge.
|
| Filename | Overview |
|---|---|
| litellm/proxy/auth/auth_utils.py | Adds bounded fallback traversal and checks fallback target dictionaries for protected request parameters. |
| litellm/proxy/auth/user_api_key_auth.py | Reuses the shared traversal to authorize every extracted fallback model. |
| litellm/proxy/litellm_pre_call_utils.py | Checks normalized provider-prefixed and comma-separated URL destination candidates. |
| litellm/llms/huggingface/embedding/handler.py | Limits direct model URL handling to explicit HTTP and HTTPS prefixes. |
| litellm/llms/huggingface/embedding/transformation.py | Removes redundant embedding endpoint selection logic. |
| litellm/llms/oobabooga/chat/oobabooga.py | Uses exact URL prefix checks for completion and embedding endpoints. |
| tests/test_litellm/proxy/auth/test_auth_utils.py | Adds tests for nested fallback validation, credential aliases, traversal limits, and caller credentials. |
| tests/test_litellm/proxy/auth/test_router_override_fallback_auth.py | Covers supported fallback shapes and nested model authorization. |
| tests/test_litellm/proxy/test_provider_url_destination_guard.py | Covers prefixed, batched, case-varied, ordinary, and allowlisted destination values. |
Reviews (2): Last reviewed commit: "fix(proxy): harden request parameter val..." | Re-trigger Greptile
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
@greptileai please review the current head e93dae5 |
|
@greptileai please review the current head 506dd68 |
PR overviewAll previously flagged issues have been addressed. No open security concerns remain on this pull request. Security reviewNo open security issues remain on this pull request. Fixed/addressed: 1 · PR risk: 0/10 |
|
@greptileai please review the current head 71be735 |
71be735 to
fa355ae
Compare
|
@greptileai please review the current head fa355ae |
fa355ae to
5818eb2
Compare
|
@greptileai please review the current head 5818eb2 |
…ination handling (BerriAI#34189) (cherry picked from commit 065faf6)
Security impact
This closes several related critical SSRF and credential-exfiltration bypasses in request-parameter and provider-destination handling. The URL-valued destination guard on
model/file_idonly checked whether the raw value began withhttp, so a provider prefix (huggingface/https://attacker) or a comma-batched entry slipped past it; downstream the prefix was stripped and the HuggingFace and Oobabooga handlers used the remaining URL as the outbound destination with the proxy's provider key attached, leaking that key to the attacker. Banned request-body params could also be smuggled through nestedfallbacksentries, and the blocklist missed thevertex_ai_credentialsalias. The fix strips prefixes and splits batches before the guard runs, tightens the handler URL checks, applies the banned-param and URL checks recursively across all fallback fields with a fail-closed depth cap, and extends the blocklist.Severity: Critical. Authenticated low-privilege attacker; provider-credential theft and internal SSRF through multiple request shapes
Relevant issues
Linear ticket
Pre-Submission checklist
Screenshots / Proof of Fix
Type
🧹 Refactoring
Changes
Tidies up how the proxy validates request-body parameters and how a couple of provider handlers select their outbound destination
The destination lookup for
modelandfile_idnow compares provider-prefixed and comma-separated values consistently, and the HuggingFace and Oobabooga handlers pick their destination with an explicit scheme-prefix check rather than a substring match. The request-body parameter checks are applied consistently across nestedfallbacks,context_window_fallbacks, andcontent_policy_fallbackson both the request root androuter_settings_override, with a bounded traversal depth, and the same traversal is reused for the fallback model resolution path. The destination-candidate helper moves intolitellm_core_utils/url_utilsso the proxy and the request path share one implementation, and one additional provider credential alias is folded into the existing request-body parameter list for consistencyQA runbook
Unit coverage lives in
tests/test_litellm/proxy/auth/test_auth_utils.py,tests/test_litellm/proxy/auth/test_router_override_fallback_auth.py, andtests/test_litellm/proxy/test_provider_url_destination_guard.py, along with the HuggingFace and Oobabooga handler tests; all pass locallyFinal Attestation