Skip to content

[Fix] Extend request body parameter restrictions to cloud provider auth fields - #26264

Merged
yuneng-berri merged 2 commits into
litellm_yj_apr22from
litellm_extend_request_body_restrictions
Apr 22, 2026
Merged

[Fix] Extend request body parameter restrictions to cloud provider auth fields#26264
yuneng-berri merged 2 commits into
litellm_yj_apr22from
litellm_extend_request_body_restrictions

Conversation

@yuneng-berri

Copy link
Copy Markdown
Contributor

Summary

is_request_body_safe() blocked api_base and base_url from request bodies but did not cover cloud-provider-specific authentication parameters. This PR adds aws_sts_endpoint, aws_web_identity_token, aws_role_name, and vertex_credentials to the existing banned_params list in that function, bringing them in line with the existing restriction pattern.

The existing escape hatches (allow_client_side_credentials: true in general_settings, or model-level configurable_clientside_auth_params) continue to apply for deployments that explicitly opt in to client-side credential passing.

Changes

Added four parameters to the banned_params list in is_request_body_safe() in litellm/proxy/auth/auth_utils.py. No other logic was modified.

Testing

  • Verified each newly banned parameter is rejected with a 401 when passed in a request body (5 checks)
  • Verified that normal requests and existing banned params (api_base, base_url) continue to behave correctly (5 checks)
  • pytest tests/test_litellm/proxy/auth/test_auth_utils.py — 56 passed

Type

🐛 Bug Fix
✅ Test

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ yuneng-berri
❌ shin-berri
You have signed the CLA already but the status is still pending? Let us recheck it.

@yuneng-berri
yuneng-berri changed the base branch from litellm_internal_staging to litellm_yj_apr22 April 22, 2026 19:41
@greptile-apps

greptile-apps Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR extends is_request_body_safe() by appending aws_sts_endpoint, aws_web_identity_token, aws_role_name, and vertex_credentials to banned_params, closing cloud-provider-specific auth-field injection vectors analogous to the existing api_base/base_url blocks. The existing opt-in escape hatches (allow_client_side_credentials, configurable_clientside_auth_params) are preserved.

Confidence Score: 4/5

Safe 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

Important Files Changed

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
Loading

Reviews (1): Last reviewed commit: "fix: extend request body parameter restr..." | Re-trigger Greptile

Comment on lines +154 to +162
banned_params = [
"api_base",
"base_url",
"user_config",
"aws_sts_endpoint",
"aws_web_identity_token",
"aws_role_name",
"vertex_credentials",
]

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

Comment on lines +154 to +162
banned_params = [
"api_base",
"base_url",
"user_config",
"aws_sts_endpoint",
"aws_web_identity_token",
"aws_role_name",
"vertex_credentials",
]

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

@veria-ai veria-ai 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.

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_credentials alias — litellm/proxy/auth/auth_utils.py

"aws_sts_endpoint",
"aws_web_identity_token",
"aws_role_name",
"vertex_credentials",

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.

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).

Suggested change
"vertex_credentials",
"vertex_credentials",
"vertex_ai_credentials",
"aws_bedrock_runtime_endpoint",
]

@yuneng-berri
yuneng-berri merged commit c71d1da into litellm_yj_apr22 Apr 22, 2026
102 checks passed
@yuneng-berri
yuneng-berri deleted the litellm_extend_request_body_restrictions branch April 22, 2026 21:56
DrishnaTrivedi added a commit to DrishnaTrivedi/litellm that referenced this pull request Jun 12, 2026
…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>
DrishnaTrivedi added a commit to DrishnaTrivedi/litellm that referenced this pull request Jun 12, 2026
…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>
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…body_restrictions

[Fix] Extend request body parameter restrictions to cloud provider auth fields
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.

3 participants