Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(proxy): strip extra_headers/headers/aws_session_token from GET /health (gh-36898)

Siraj637909785eed616fdb
diff --git a/litellm/proxy/health_check.py b/litellm/proxy/health_check.py
index f9d408fb7de..83919e1ddee 100644
--- a/litellm/proxy/health_check.py
+++ b/litellm/proxy/health_check.py
@@ -27,6 +27,9 @@ ILLEGAL_DISPLAY_PARAMS: Final = [
"vertex_credentials",
"aws_access_key_id",
"aws_secret_access_key",
+ "aws_session_token",
+ "extra_headers",
+ "headers",
"exception", # internal; not JSON-serializable, never for display
"litellm_metadata", # internal tracking metadata with auth objects; not for display
]
diff --git a/tests/test_litellm/proxy/health_endpoints/test_health_endpoints.py b/tests/test_litellm/proxy/health_endpoints/test_health_endpoints.py
index e2705bd5fec..2d3c90a2b9e 100644
--- a/tests/test_litellm/proxy/health_endpoints/test_health_endpoints.py
+++ b/tests/test_litellm/proxy/health_endpoints/test_health_endpoints.py
@@ -2367,6 +2367,35 @@ def test_clean_endpoint_data_strips_credentials_keeps_routing_fields():
assert cleaned.get("api_version") == "2024-10-21"
+def test_clean_endpoint_data_strips_extra_headers_and_aws_session_token():
+ """
+ gh-36898: GET /health must not leak provider credentials that live in
+ `extra_headers` / `headers` / `aws_session_token`. Before the fix these
+ were returned in plaintext (api_key was stripped, but these were not).
+ """
+ from litellm.proxy.health_check import _clean_endpoint_data
+
+ raw = {
+ "model": "openai/gpt-4o",
+ "api_base": "https://example.test/v1",
+ "extra_headers": {
+ "Authorization": "Bearer CANARY_EXTRA_HEADERS_AUTHORIZATION",
+ "x-goog-api-key": "CANARY_X_GOOG_API_KEY_VALUE",
+ "api-key": "CANARY_AZURE_STYLE_API_KEY",
+ },
+ "headers": {"X-Custom": "CANARY_HEADER_VALUE"},
+ "aws_session_token": "CANARY_AWS_SESSION_TOKEN_VALUE",
+ }
+
+ cleaned = _clean_endpoint_data(raw, details=True)
+
+ assert "extra_headers" not in cleaned
+ assert "headers" not in cleaned
+ assert "aws_session_token" not in cleaned
+ # routing/admin field still present
+ assert cleaned.get("api_base") == "https://example.test/v1"
+
+
class TestConfigBaseForHealthCheck:
"""A request that sets its own connection fields gets a base without the
configuration's credentials; anything it leaves unset still comes from