[Fix] Extend request body parameter restrictions to cloud provider auth fields - #26264
Conversation
[Infra] Promote internal staging to main
|
|
Greptile SummaryThis PR extends Confidence Score: 4/5Safe to merge; all findings are P2 and do not block correctness of the new restrictions. The one-line list expansion is correct and low-risk. Two P2 concerns remain: no new test cases were added to verify the new entries, and sibling AWS credential params (aws_access_key_id, aws_secret_access_key, aws_session_token) are still not banned, leaving coverage incomplete. litellm/proxy/auth/auth_utils.py — banned_params list and its test coverage in tests/proxy_unit_tests/test_proxy_utils.py
|
| Filename | Overview |
|---|---|
| litellm/proxy/auth/auth_utils.py | Adds aws_sts_endpoint, aws_web_identity_token, aws_role_name, and vertex_credentials to the banned_params list in is_request_body_safe(); change is minimal and correct but leaves aws_access_key_id/aws_secret_access_key/aws_session_token uncovered and ships no new tests. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Incoming Request Body] --> B{banned param present?}
B -- No --> Z[Return True - safe]
B -- Yes --> C{check_complete_credentials?}
C -- True --> Z
C -- False --> D{allow_client_side_credentials == True?}
D -- Yes --> Z
D -- No --> E{_allow_model_level_clientside_configurable_parameters?}
E -- Yes --> Z
E -- No --> F[Raise ValueError - 401 Rejected]
subgraph banned_params
P1[api_base]
P2[base_url]
P3[user_config]
P4[aws_sts_endpoint new]
P5[aws_web_identity_token new]
P6[aws_role_name new]
P7[vertex_credentials new]
end
Reviews (1): Last reviewed commit: "fix: extend request body parameter restr..." | Re-trigger Greptile
| banned_params = [ | ||
| "api_base", | ||
| "base_url", | ||
| "user_config", | ||
| "aws_sts_endpoint", | ||
| "aws_web_identity_token", | ||
| "aws_role_name", | ||
| "vertex_credentials", | ||
| ] |
There was a problem hiding this comment.
No new tests for newly banned params
The PR description claims five per-param rejection checks, but no test cases covering aws_sts_endpoint, aws_web_identity_token, aws_role_name, or vertex_credentials appear in tests/proxy_unit_tests/test_proxy_utils.py (the only file that calls is_request_body_safe). The existing 56 passing tests don't exercise the new entries, so a future regression could silently remove these protections undetected.
| banned_params = [ | ||
| "api_base", | ||
| "base_url", | ||
| "user_config", | ||
| "aws_sts_endpoint", | ||
| "aws_web_identity_token", | ||
| "aws_role_name", | ||
| "vertex_credentials", | ||
| ] |
There was a problem hiding this comment.
Other sensitive AWS credential params not yet banned
aws_access_key_id, aws_secret_access_key, and aws_session_token are accepted by bedrock's credential helper (see litellm/llms/bedrock/common_utils.py lines 257–297) but are absent from banned_params. A client that passes these fields forces the proxy to authenticate to AWS with caller-controlled credentials, potentially bypassing per-model access controls or audit boundaries. The existing escape hatches (allow_client_side_credentials, configurable_clientside_auth_params) already give operators an explicit opt-in path — consider extending the ban to these fields as well for consistency.
There was a problem hiding this comment.
High: Incomplete restriction of cloud provider parameters allows SSRF via aws_bedrock_runtime_endpoint
This PR extends the request body parameter blocklist to cover several AWS and Vertex AI auth fields. However, aws_bedrock_runtime_endpoint is not included. This parameter controls the destination URL for Bedrock API calls and is functionally equivalent to api_base — an authenticated user can set it to redirect requests (carrying the operator's SigV4-signed AWS credentials) to an attacker-controlled endpoint. Additionally, vertex_ai_credentials is an alias for vertex_credentials that bypasses the ban.
- high: SSRF via unbanned
aws_bedrock_runtime_endpoint— litellm/proxy/auth/auth_utils.py - medium: ban bypass via
vertex_ai_credentialsalias — litellm/proxy/auth/auth_utils.py
| "aws_sts_endpoint", | ||
| "aws_web_identity_token", | ||
| "aws_role_name", | ||
| "vertex_credentials", |
There was a problem hiding this comment.
High: SSRF via unbanned aws_bedrock_runtime_endpoint
aws_bedrock_runtime_endpoint controls the destination URL for all Bedrock API calls (see base_aws_llm.py:1114-1150). It's functionally equivalent to api_base for Bedrock models. An authenticated user can set this in the request body to redirect the proxy's SigV4-signed request to an attacker-controlled server, leaking the operator's AWS credentials.
Also missing: vertex_ai_credentials (alias for vertex_credentials — see vertex_llm_base.py:748-753).
| "vertex_credentials", | |
| "vertex_credentials", | |
| "vertex_ai_credentials", | |
| "aws_bedrock_runtime_endpoint", | |
| ] |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
…p from BerriAI#26264 (CWE-918) aiohttp_handler.py was not covered by the SSRF protection in PR BerriAI#26264. User-controlled api_base was passed directly to session.post() without IP validation. Protection added: - Blocks RFC-1918, loopback, link-local (169.254/16, fe80::/10), CGNAT, 0.0.0.0/8, IPv6 ULA/loopback - Unwraps IPv4-mapped IPv6 (::ffff:x.x.x.x) before network check - Validates ALL getaddrinfo answers to prevent A-record rotation bypass - _SSRFGuardResolver (AbstractResolver) validates IPs at TCP-connection time inside aiohttp's own connection loop — covers redirect targets and eliminates DNS-rebinding TOCTOU - Default ClientSession creation uses TCPConnector(resolver=_SSRFGuardResolver()) - Sync path (_make_common_sync_call via httpx) guarded with preflight check Tests: - 18 new tests in tests/test_litellm/llms/test_aiohttp_ssrf_protection.py - Updated 4 existing tests in test_aiohttp_handler.py to mock TCPConnector Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…p from BerriAI#26264 (CWE-918) aiohttp_handler.py was not covered by the SSRF protection in PR BerriAI#26264. User-controlled api_base was passed directly to session.post() without IP validation. Protection added: - Blocks RFC-1918, loopback, link-local (169.254/16, fe80::/10), CGNAT, 0.0.0.0/8, IPv6 ULA/loopback - Unwraps IPv4-mapped IPv6 (::ffff:x.x.x.x) before network check - Validates ALL getaddrinfo answers to prevent A-record rotation bypass - _SSRFGuardResolver (AbstractResolver) validates IPs at TCP-connection time inside aiohttp's own connection loop — covers redirect targets and eliminates DNS-rebinding TOCTOU - Default ClientSession creation uses TCPConnector(resolver=_SSRFGuardResolver()) - Sync path (_make_common_sync_call via httpx) guarded with preflight check Tests: - 18 new tests in tests/test_litellm/llms/test_aiohttp_ssrf_protection.py - Updated 4 existing tests in test_aiohttp_handler.py to mock TCPConnector Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…body_restrictions [Fix] Extend request body parameter restrictions to cloud provider auth fields
Summary
is_request_body_safe()blockedapi_baseandbase_urlfrom request bodies but did not cover cloud-provider-specific authentication parameters. This PR addsaws_sts_endpoint,aws_web_identity_token,aws_role_name, andvertex_credentialsto the existingbanned_paramslist in that function, bringing them in line with the existing restriction pattern.The existing escape hatches (
allow_client_side_credentials: trueingeneral_settings, or model-levelconfigurable_clientside_auth_params) continue to apply for deployments that explicitly opt in to client-side credential passing.Changes
Added four parameters to the
banned_paramslist inis_request_body_safe()inlitellm/proxy/auth/auth_utils.py. No other logic was modified.Testing
api_base,base_url) continue to behave correctly (5 checks)pytest tests/test_litellm/proxy/auth/test_auth_utils.py— 56 passedType
🐛 Bug Fix
✅ Test