The web_crawl tool performs its SSRF check only on the initial URL: it resolves the hostname once
with socket.gethostbyname and rejects private/loopback/link-local results. It then passes the URL to
a fetcher that uses httpx.Client(follow_redirects=True) - or urllib.request.urlopen when httpx is
absent, which also follows redirects - and re-resolves the hostname at connect time, with no further
validation. This validate-here/fetch-there gap is bypassable two independent ways: HTTP redirects and
DNS rebinding.
Affected code: src/praisonai-agents/praisonaiagents/tools/web_crawl_tools.py
- Single-shot validation (lines 229-238):
if os.environ.get("ALLOW_LOCAL_CRAWL") != "true":
ip_str = socket.gethostbyname(hostname) # resolved ONCE, at validation time
ip = ipaddress.ip_address(ip_str)
if ip.is_loopback or ip.is_private or ip.is_link_local or ip.is_multicast or ip.is_unspecified:
continue # rejected
url_list.append(u)
- Vulnerable fetch (_crawl_with_httpx, lines 142 / 149): follows redirects, re-resolves DNS, no re-check:
with httpx.Client(follow_redirects=True, timeout=30.0) as client: response = client.get(url)
fallback: urllib.request.urlopen(url, timeout=30) (also follows redirects by default)
- web_crawl / crawl_web are registered tools (tools/init.py:156-157); httpx is the default fallback
provider (dispatch at web_crawl_tools.py:269).
The two bypasses:
- Redirect: validation approves an attacker domain resolving to a public IP; attacker server replies
302 Location: http://169.254.169.254/... (or any internal host); the fetcher follows it unchecked.
- DNS rebinding (TOCTOU): validator's gethostbyname and fetcher's connect-time resolution are
independent; a low-TTL attacker domain answers public to the validator and private/loopback to fetch.
Impact:
An agent with web_crawl - driven by direct input or indirect prompt injection - can be made to…