From 059f1fcad45e4b58d36de994946facc684f8701c Mon Sep 17 00:00:00 2001 From: maycuatroi1 <5876946+maycuatroi1@users.noreply.github.com> Date: Sat, 15 Aug 2026 06:56:55 +0700 Subject: [PATCH] fix(guardrails): satisfy type-discipline budget on the SSRF validation block http_request re-bound the `headers` parameter when merging the restored Host header (LIT011, budget +1 over the ceiling). Bind `request_headers` instead and pass that to _execute_http_request. --- .../guardrails/guardrail_hooks/custom_code/primitives.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/guardrails/guardrail_hooks/custom_code/primitives.py b/litellm/proxy/guardrails/guardrail_hooks/custom_code/primitives.py index 89eb79e4ce7..431e7c11a7a 100644 --- a/litellm/proxy/guardrails/guardrail_hooks/custom_code/primitives.py +++ b/litellm/proxy/guardrails/guardrail_hooks/custom_code/primitives.py @@ -465,10 +465,11 @@ async def http_request( # be reached by adding them to `user_url_allowed_hosts` in general_settings. # `litellm.user_url_validation = False` disables this check entirely. validated_url = url + request_headers = headers if getattr(litellm, "user_url_validation", True): try: validated_url, host_header = validate_url(url) - headers = {**(headers or {}), "Host": host_header} + request_headers = {**(headers or {}), "Host": host_header} except (SSRFError, ValueError) as e: verbose_proxy_logger.warning("Custom code http_request SSRF blocked: %s", e) return _http_error_response(f"Blocked: {e}") @@ -492,7 +493,7 @@ async def http_request( ) try: - response: Final = await _execute_http_request(client, method, validated_url, headers, body, timeout) + response: Final = await _execute_http_request(client, method, validated_url, request_headers, body, timeout) return _http_success_response(response) except httpx.TimeoutException as e: