Skip to content
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
91bfbe6
fix(proxy): enforce organization boundaries in admin operations
stuxf Apr 16, 2026
815a2be
test: add regression tests for cross-org admin escalation
stuxf Apr 16, 2026
74a49b5
fix(proxy): read guardrail config from admin metadata, fix tag routin…
stuxf Apr 16, 2026
3cd5796
refactor: extract admin metadata helper, hoist loop-invariant tag res…
stuxf Apr 16, 2026
34e9be1
fix: merge team metadata in admin helper, remove turn_off_message_log…
stuxf Apr 16, 2026
413f898
test: update dynamic callback params test for turn_off_message_loggin…
stuxf Apr 16, 2026
9363f36
fix(proxy): add SSRF protection via resolve-and-rewrite for user-supp…
stuxf Apr 16, 2026
d15196b
fix(proxy): add safe_get/async_safe_get with redirect validation
stuxf Apr 16, 2026
037fb57
fix: preserve caller headers across redirect hops in safe_get
stuxf Apr 16, 2026
b94aaa7
fix: skip DNS resolution for base64 data in token counter, add unit t…
stuxf Apr 16, 2026
62ec396
test: mock SSRF validation in openapi spec URL test
stuxf Apr 16, 2026
814d03d
fix: fail-closed on unparseable IPs, rewrite HTTPS when SSL verify di…
stuxf Apr 16, 2026
e2a0c96
fix: redirect loop was dead code, clean up imports
stuxf Apr 16, 2026
00b25d6
fix: sync redirect bypass, Host header port, redirect loop dead code
stuxf Apr 16, 2026
1ba2be7
refactor: move url_utils to litellm_core_utils to avoid proxy dependency
stuxf Apr 16, 2026
30c6556
test: bypass SSRF validation in image handling tests
stuxf Apr 16, 2026
f5a9218
chore: remove unused asyncio import
stuxf Apr 16, 2026
1f50c6f
test: mock DNS resolution, hoist httpx import to module level
stuxf Apr 16, 2026
22572ea
fix: merge admin metadata from both metadata and litellm_metadata
stuxf Apr 16, 2026
1d3dda9
feat: add admin opt-out for user URL validation
stuxf Apr 16, 2026
d060169
fix(proxy): strip user_api_key_metadata injection slots from user input
stuxf Apr 16, 2026
0602564
fix: switch blocklist to RFC 6890 via ipaddress.is_global, block mult…
stuxf Apr 16, 2026
aa2f05f
style: use 'is not None' for port check (handle port 0 explicitly)
stuxf Apr 16, 2026
0e62add
fix(proxy): gate caller-supplied routing/budget tags behind allow_cli…
stuxf Apr 16, 2026
8526628
test: update tag-merge tests for default-deny client tag policy
stuxf Apr 16, 2026
af8d479
chore(proxy): emit warning when caller-supplied tags are stripped
stuxf Apr 16, 2026
9622864
test: set allow_client_tags on duplicate-tag merge test
stuxf Apr 16, 2026
db19f24
fix(proxy): move metadata strip after JSON-string parse
stuxf Apr 16, 2026
dc8e03b
fix(proxy): expand _guardrail_modification_check to cover all bypass …
stuxf Apr 16, 2026
76aa97f
fix(proxy): close three variant metadata/tag injection paths
stuxf Apr 16, 2026
b4e98d1
fix(proxy): close 6 more metadata/tag variant bypasses
stuxf Apr 17, 2026
467166f
fix(proxy): enforce per-target org authorization on /user/delete
stuxf Apr 17, 2026
8c0668f
perf: batch target membership lookup in delete_user to avoid N+1
stuxf Apr 17, 2026
1320632
fix(proxy): strip root-level data['tags'] alongside metadata tags
stuxf Apr 17, 2026
cdb2994
fix: align agent endpoint and routing permission checks with existing…
yuneng-berri Apr 17, 2026
662d055
fix(proxy): close three more org-boundary escape paths
stuxf Apr 17, 2026
c7c3df2
fix(proxy): extend /key/update admin check to non-budget fields
stuxf Apr 17, 2026
e3b5579
fix(proxy): close /organization member_delete + role-escalation gaps
stuxf Apr 17, 2026
bcb2ea6
fix: add explicit admin bypass to agent access checks for consistency
yuneng-berri Apr 17, 2026
50a6324
Merge pull request #25904 from stuxf/fix/org-boundary-enforcement
yuneng-berri Apr 17, 2026
32714a4
Merge pull request #25905 from stuxf/fix/metadata-security-controls
yuneng-berri Apr 17, 2026
7c66edb
Merge pull request #25906 from stuxf/fix/ssrf-url-validation
yuneng-berri Apr 17, 2026
ee2cf0e
fix: address three CI failures from recent security PR merges
yuneng-berri Apr 17, 2026
b9f5be8
Merge pull request #25922 from BerriAI/litellm_a2a_agent_acl
yuneng-berri Apr 18, 2026
11c3270
Merge remote-tracking branch 'origin/litellm_internal_staging' into l…
yuneng-berri Apr 18, 2026
ecf65f5
Merge remote-tracking branch 'origin/litellm_internal_staging' into l…
yuneng-berri Apr 18, 2026
9c0b73e
[Fix] should_create_missing_views returns False for reltuples=0 (fals…
yuneng-berri Apr 18, 2026
f483f1e
Merge remote-tracking branch 'origin/litellm_internal_staging' into l…
yuneng-berri Apr 18, 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
2 changes: 2 additions & 0 deletions litellm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@
ssl_verify: Union[str, bool] = True
ssl_security_level: Optional[str] = None
ssl_certificate: Optional[str] = None
user_url_validation: bool = True
user_url_allowed_hosts: List[str] = []
ssl_ecdh_curve: Optional[str] = (
None # Set to 'X25519' to disable PQC and improve performance
)
Expand Down
42 changes: 30 additions & 12 deletions litellm/integrations/custom_guardrail.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,26 +255,44 @@ def _validate_event_hook_list_is_in_supported_event_hooks(
f"Event hook {event_hook} is not in the supported event hooks {supported_event_hooks}"
)

@staticmethod
def _get_admin_metadata(data: dict) -> dict:
"""Return merged admin-configured key and team metadata from the request data.

The proxy may inject admin metadata (user_api_key_metadata,
user_api_key_team_metadata) into either ``metadata`` or
``litellm_metadata`` depending on endpoint. Check both so a caller
cannot shadow admin config by pre-populating the other key.
Key-level settings override team-level.
"""
team_meta: dict = {}
key_meta: dict = {}
for key in ("metadata", "litellm_metadata"):
# Defensive: an unparsed JSON-string metadata could leak past the
# proxy's normal parse path; don't AttributeError on .get().
meta = data.get(key)
if not isinstance(meta, dict):
continue
team_meta = meta.get("user_api_key_team_metadata") or team_meta
key_meta = meta.get("user_api_key_metadata") or key_meta
return {**team_meta, **key_meta}

def get_disable_global_guardrail(self, data: dict) -> Optional[bool]:
"""
Returns True if the global guardrail should be disabled
Returns True if the global guardrail should be disabled.

Reads from admin-configured key/team metadata only, not from
the request body, to prevent callers from disabling guardrails.
"""
if "disable_global_guardrails" in data:
return data["disable_global_guardrails"]
metadata = data.get("litellm_metadata") or data.get("metadata", {})
if "disable_global_guardrails" in metadata:
return metadata["disable_global_guardrails"]
return False
return self._get_admin_metadata(data).get("disable_global_guardrails", False)

def get_opted_out_global_guardrails_from_metadata(self, data: dict) -> List[str]:
"""
Returns the list of global guardrail names the team/key has opted out of.

Reads from admin-configured key/team metadata only.
"""
if "opted_out_global_guardrails" in data:
value = data["opted_out_global_guardrails"]
return value if isinstance(value, list) else []
metadata = data.get("litellm_metadata") or data.get("metadata", {})
value = metadata.get("opted_out_global_guardrails")
value = self._get_admin_metadata(data).get("opted_out_global_guardrails")
return value if isinstance(value, list) else []

def _is_valid_response_type(self, result: Any) -> bool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def _raise_env_reference_error(param: str, *, source: str) -> None:
"braintrust_host",
"slack_webhook_url",
"lunary_public_key",
"turn_off_message_logging",
]


Expand Down
5 changes: 3 additions & 2 deletions litellm/litellm_core_utils/prompt_templates/image_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from litellm import verbose_logger
from litellm.caching.caching import InMemoryCache
from litellm.constants import MAX_IMAGE_URL_DOWNLOAD_SIZE_MB
from litellm.litellm_core_utils.url_utils import async_safe_get, safe_get

MAX_IMGS_IN_MEMORY = 10

Expand Down Expand Up @@ -84,7 +85,7 @@ async def async_convert_url_to_base64(url: str) -> str:
client = litellm.module_level_aclient
for _ in range(3):
try:
response = await client.get(url, follow_redirects=True)
response = await async_safe_get(client, url)
return _process_image_response(response, url)
except litellm.ImageFetchError:
raise
Expand All @@ -109,7 +110,7 @@ def convert_url_to_base64(url: str) -> str:
client = litellm.module_level_client
for _ in range(3):
try:
response = client.get(url, follow_redirects=True)
response = safe_get(client, url)
return _process_image_response(response, url)
except litellm.ImageFetchError:
raise
Expand Down
17 changes: 10 additions & 7 deletions litellm/litellm_core_utils/token_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
)
from litellm.litellm_core_utils.default_encoding import encoding as default_encoding
from litellm.llms.custom_httpx.http_handler import _get_httpx_client
from litellm.litellm_core_utils.url_utils import safe_get
from litellm.types.llms.anthropic import (
AnthropicMessagesToolResultParam,
AnthropicMessagesToolUseParam,
Expand Down Expand Up @@ -210,13 +211,15 @@ def get_image_dimensions(
Tuple[int, int]: The width and height of the image.
"""
img_data = None
try:
# Try to open as URL
client = _get_httpx_client()
response = client.get(data)
img_data = response.read()
except Exception:
# If not URL, assume it's base64
if data.startswith(("http://", "https://")):
try:
client = _get_httpx_client()
response = safe_get(client, data)
img_data = response.read()
except Exception:
pass
if img_data is None:
# Not a URL or fetch failed — assume base64
_header, encoded = data.split(",", 1)
img_data = base64.b64decode(encoded)

Expand Down
Loading
Loading