Skip to content

fix(url_safety): allow DNS failure in proxy/sandbox environments (salvage of #68469 by @kuangmi-bit) - #70874

Merged
teknium1 merged 2 commits into
mainfrom
salvage-68469
Jul 24, 2026
Merged

fix(url_safety): allow DNS failure in proxy/sandbox environments (salvage of #68469 by @kuangmi-bit)#70874
teknium1 merged 2 commits into
mainfrom
salvage-68469

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Web tools work again in proxy-only sandboxes (Docker + Squid, NVIDIA OpenShell, iron-proxy egress containers) where direct DNS is blocked at the network level: when an HTTP proxy env var is configured, is_safe_url() delegates hostname resolution to the proxy instead of failing closed on the pre-flight DNS check. Fixes #32217. Salvage of #68469 by @kuangmi-bit with authorship preserved, plus a hardening pass.

Root cause: is_safe_url() requires socket.getaddrinfo() to succeed before allowing any outbound request. In proxy-only environments DNS is intentionally unavailable — only HTTP(S) through the proxy works — so every web tool call was blocked even though the request would succeed. This includes our own iron-proxy egress sandboxes (#70848) when the container has no direct DNS.

Changes

  • tools/url_safety.py (salvaged from fix(url_safety): allow DNS failure in proxy/sandbox environments #68469): on gaierror, if HTTP_PROXY/HTTPS_PROXY/ALL_PROXY (any case) is set, delegate resolution to the proxy and allow; otherwise fail closed as before. Blocked-hostname floor (cloud metadata) runs before the skip.
  • tools/url_safety.py (our hardening): literal-IP hostnames never take the delegation path — an IP needs no DNS, so a resolution failure on one is not a proxy symptom; they stay on the fail-closed path and the blocked-IP floor.
  • tests/tools/test_url_safety.py: new TestProxyEnvironmentDnsDelegation class (7 regression tests: delegation fires, floor intact for metadata hostname + literal metadata IP + private IP, DNS-success path unchanged under proxy, empty proxy var ignored) and ambient-proxy-env guards on the 3 pre-existing DNS-failure tests.

Validation

Check Result
tests/tools/test_url_safety.py 144 passed, 0 failed
E2E: proxy env + broken DNS → public hostname allowed (proxy-side resolution)
E2E: proxy env + broken DNS → metadata hostname / metadata IP / private IP all blocked
E2E: no proxy + broken DNS blocked (fail-closed preserved)

Infographic

url_safety proxy DNS delegation

sg-architect and others added 2 commits July 24, 2026 09:59
When the runtime blocks direct DNS (NVIDIA OpenShell, Docker + Squid,
corporate proxy with DNS-only-via-proxy), socket.getaddrinfo() fails
and is_safe_url() blocks *all* requests — including legitimate public
URLs via the configured proxy.

Add _proxy_is_configured() helper that checks HTTPS_PROXY, HTTP_PROXY,
http_proxy, https_proxy, ALL_PROXY, all_proxy.  When DNS fails AND a
proxy is configured, delegate DNS resolution to the proxy rather than
blocking outright.

Blocked hostnames (metadata.google.internal, 169.254.169.254, etc.)
are checked BEFORE DNS resolution, so cloud metadata endpoints remain
blocked regardless of proxy status.

Fixes #32217
…closed + regression tests

Follow-up on the salvaged #68469 commit:
- Literal-IP hostnames never take the proxy DNS-delegation path (a
  getaddrinfo failure on a literal IP is not a proxy-environment
  symptom, and IPs need no DNS) — keeps the private-IP/metadata floor
  intact under proxy env vars.
- Adds TestProxyEnvironmentDnsDelegation: delegation fires only for
  hostnames, metadata hostname/IP floor holds, DNS-success path
  unchanged, empty proxy var ignored.
- Guards the three pre-existing DNS-failure tests against ambient
  proxy env vars so they don't flake on developer machines.
@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on ffc2b85

all good!

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/tools Tool registry, model_tools, toolsets tool/web Web search and extraction labels Jul 24, 2026
@teknium1
teknium1 merged commit 4a0b84e into main Jul 24, 2026
41 checks passed
@teknium1
teknium1 deleted the salvage-68469 branch July 24, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists tool/web Web search and extraction type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSRF check blocks web tools inside NVIDIA OpenShell sandbox (DNS unavailable by design)

2 participants