fix(proxy): ban aws_profile_name from request bodies

This commit is contained in:
mateo-berri 2026-07-12 00:49:08 -07:00
parent 3e9e52042a
commit fe9722777e
3 changed files with 43 additions and 0 deletions

View file

@ -251,6 +251,7 @@ _BANNED_REQUEST_BODY_PARAMS: Tuple[str, ...] = (
"aws_sts_endpoint",
"aws_web_identity_token",
"aws_role_name",
"aws_profile_name",
"vertex_credentials",
# Azure managed-identity / federated-auth token. The Azure provider
# transformer reads ``azure_ad_token`` (top-level or via

View file

@ -1749,6 +1749,47 @@ class TestIsRequestBodySafeBlocksBedrockProjectOverride:
)
class TestIsRequestBodySafeBlocksAwsProfileOverride:
def test_aws_profile_name_in_request_body_is_rejected(self):
with pytest.raises(ValueError, match="aws_profile_name"):
is_request_body_safe(
request_body={
"model": "bedrock/anthropic.claude-v2",
"aws_profile_name": "any-profile-on-the-proxy-host",
},
general_settings={},
llm_router=None,
model="bedrock/anthropic.claude-v2",
)
def test_aws_profile_name_with_api_key_still_rejected(self):
with pytest.raises(ValueError, match="aws_profile_name"):
is_request_body_safe(
request_body={
"model": "bedrock/anthropic.claude-v2",
"api_key": "sk-anything",
"aws_profile_name": "any-profile-on-the-proxy-host",
},
general_settings={},
llm_router=None,
model="bedrock/anthropic.claude-v2",
)
def test_admin_opt_in_proxy_wide_allows_aws_profile_name(self):
assert (
is_request_body_safe(
request_body={
"model": "bedrock/anthropic.claude-v2",
"aws_profile_name": "byok-profile",
},
general_settings={"allow_client_side_credentials": True},
llm_router=None,
model="bedrock/anthropic.claude-v2",
)
is True
)
class TestIsRequestBodySafeBlocksNVCFFunctionOverride:
"""``nvcf_function_id`` is rejected as a request-body param unless the
admin opted in proxy-wide or per-deployment."""

View file

@ -23,6 +23,7 @@ from litellm.proxy.auth.auth_utils import is_request_body_safe # noqa: E402
"aws_web_identity_token",
"aws_sts_endpoint",
"aws_role_name",
"aws_profile_name",
"api_base",
"base_url",
"vertex_credentials",