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]

address review feedback

Yuneng Jiang6baee0dfcbe3
diff --git a/docs/my-website/docs/oidc.md b/docs/my-website/docs/oidc.md
index 4ff045ada77..c4b82a08d17 100644
--- a/docs/my-website/docs/oidc.md
+++ b/docs/my-website/docs/oidc.md
@@ -57,10 +57,11 @@ oidc/config_name_here/
#### Unofficial Providers (not recommended)
-For the unofficial `file` provider, you can use the following format:
+For the unofficial `file` provider, you can use the following format
+(note the double slash — the path after `oidc/file/` must be absolute):
```
-oidc/file/var/run/secrets/my-token
+oidc/file//var/run/secrets/my-token
```
For safety, the resolved path must live inside an allowed credential
diff --git a/litellm/litellm_core_utils/initialize_dynamic_callback_params.py b/litellm/litellm_core_utils/initialize_dynamic_callback_params.py
index bb31ba75109..b80907e8ec7 100644
--- a/litellm/litellm_core_utils/initialize_dynamic_callback_params.py
+++ b/litellm/litellm_core_utils/initialize_dynamic_callback_params.py
@@ -1,4 +1,6 @@
from typing import Dict, Optional
+
+from litellm._logging import verbose_logger
from litellm.types.utils import StandardCallbackDynamicParams
@@ -50,8 +52,12 @@ def initialize_standard_callback_dynamic_params(
if param in kwargs:
_param_value = kwargs.get(param)
if _is_env_reference(_param_value):
- # Skip request-supplied environment references; these must
- # come from server-side configuration only.
+ verbose_logger.warning(
+ "Dropping callback param '%s': os.environ/ references "
+ "in request-supplied parameters are not resolved. "
+ "Configure this value server-side instead.",
+ param,
+ )
continue
standard_callback_dynamic_params[param] = _param_value # type: ignore
@@ -66,6 +72,13 @@ def initialize_standard_callback_dynamic_params(
if param not in standard_callback_dynamic_params and param in metadata:
_param_value = metadata.get(param)
if _is_env_reference(_param_value):
+ verbose_logger.warning(
+ "Dropping callback param '%s' from metadata: "
+ "os.environ/ references in request-supplied "
+ "parameters are not resolved. Configure this "
+ "value server-side instead.",
+ param,
+ )
continue
standard_callback_dynamic_params[param] = _param_value # type: ignore
diff --git a/litellm/proxy/health_endpoints/_health_endpoints.py b/litellm/proxy/health_endpoints/_health_endpoints.py
index 2cb9a136e12..a6caf9d0803 100644
--- a/litellm/proxy/health_endpoints/_health_endpoints.py
+++ b/litellm/proxy/health_endpoints/_health_endpoints.py
@@ -40,15 +40,15 @@ from litellm.proxy.middleware.in_flight_requests_middleware import (
#### Health ENDPOINTS ####
-def _reject_os_environ_references(params: dict) -> dict:
+def _reject_os_environ_references(params: dict) -> None:
"""
Validate that the provided params do not contain any ``os.environ/``
references. Values with that prefix are expected to come only from
server-side configuration (already resolved before reaching here). If a
- request-supplied value still carries the prefix, reject it.
+ request-supplied value still carries the prefix, raise ``HTTPException``.
"""
if not isinstance(params, dict):
- return params
+ return
stack: list[object] = [params]
seen: set[int] = {id(params)}
@@ -74,8 +74,6 @@ def _reject_os_environ_references(params: dict) -> dict:
seen.add(id(value))
stack.append(value)
- return params
-
def get_callback_identifier(callback):
"""
diff --git a/litellm/secret_managers/main.py b/litellm/secret_managers/main.py
index 10042b6d46f..a560f5222b9 100644
--- a/litellm/secret_managers/main.py
+++ b/litellm/secret_managers/main.py
@@ -42,6 +42,12 @@ def _resolve_oidc_file_path(requested_path: str) -> str:
Resolve ``requested_path`` and verify it falls within one of the allowed
credential directories. Raises ``ValueError`` otherwise.
"""
+ if not os.path.isabs(requested_path):
+ raise ValueError(
+ "oidc/file path must be absolute. Use the format "
+ "'oidc/file//var/run/secrets/<name>' (note the leading slash "
+ "after 'oidc/file/')."
+ )
resolved = os.path.realpath(requested_path)
for allowed in _get_oidc_allowed_credential_dirs():
try:
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 7e647d7e9f0..097de13df13 100644
--- a/tests/test_litellm/proxy/health_endpoints/test_health_endpoints.py
+++ b/tests/test_litellm/proxy/health_endpoints/test_health_endpoints.py
@@ -452,7 +452,7 @@ async def test_test_model_connection_loads_config_from_router():
# Mock _reject_os_environ_references
def mock_reject_os_environ(params):
- return params
+ return None
with patch(
"litellm.proxy.proxy_server.prisma_client",
diff --git a/tests/test_litellm/secret_managers/test_secret_managers_main.py b/tests/test_litellm/secret_managers/test_secret_managers_main.py
index 89155d51b57..d90b68198b7 100644
--- a/tests/test_litellm/secret_managers/test_secret_managers_main.py
+++ b/tests/test_litellm/secret_managers/test_secret_managers_main.py
@@ -222,6 +222,12 @@ def test_oidc_file_rejects_path_outside_allowlist(tmp_path, monkeypatch):
get_secret(f"oidc/file/{outside_file}")
+def test_oidc_file_rejects_relative_path(tmp_path, monkeypatch):
+ monkeypatch.setenv("LITELLM_OIDC_ALLOWED_CREDENTIAL_DIRS", str(tmp_path))
+ with pytest.raises(ValueError, match="must be absolute"):
+ get_secret("oidc/file/relative/path/token")
+
+
def test_oidc_env_success(mock_env):
mock_env["CUSTOM_TOKEN"] = "env_token"