AAK-LANGCHAIN-SSRF-REDIR-001
Validate-then-fetch SSRF (redirects enabled past allow-list)
| Field | Value |
|---|---|
| Severity | HIGH |
| Category | TRANSPORT_SECURITY |
| Shipped | v0.3.5 (2026-04-25) |
| Scanner | agent_audit_kit/scanners/ssrf_redirect.py |
| CWE | CWE-601 (Open Redirect) + CWE-918 (SSRF) |
| OWASP MCP | MCP05:2025 (Command Injection & Execution) |
| OWASP Agentic | ASI02 (Tool Misuse and Exploitation) |
| AICM | IVS-04, AIS-08 |
| CVE | CVE-2026-41481 |
| Advisory | GHSA-fv5p-p927-qmxr |
What it catches
A function calls a known SSRF guard helper
(validate_safe_url, is_safe_url, validateSafeUrl, ensure_safe_url,
check_safe_url, ssrf_guard, is_url_safe) and then fetches the same
URL via requests.get / httpx.get / urllib.request.urlopen /
fetch / axios.get / got without disabling redirects.
The allow-list fires once on the URL the caller supplied, but
requests follows 3xx by default. A 302 from an attacker-controlled
host into http://169.254.169.254/..., http://localhost, or another
blocked target bypasses the guard and pulls the response back into the
calling context.
CVE-2026-41481 is the canonical example: langchain-text-splitters <
1.1.2's HTMLHeaderTextSplitter.split_text_from_url() did exactly
this. Same shape applies in any agent-tooling code that does
validate→fetch without allow_redirects=False.
Detection
The Python pass walks the AST and orders calls by source line (ast.walk
is BFS, so naive walk-order would visit requests.get before
validate_safe_url when the validator is inside an if and the fetch
is on the next line). For each function:
- First call to a
_VALIDATOR_NAMEShelper setsvalidator_seen=True. - Subsequent call whose attribute name is in
_FETCH_NAMESfires the rule unless one of these kwargs disables redirects: allow_redirects=Falsefollow_redirects=Falsemax_redirects=0redirect="manual"/redirect="error"
The TS/JS pass is a regex pair: _TS_VALIDATOR_RE followed within 2 KB
by _TS_FETCH_RE, suppress on _TS_REDIRECT_OFF_RE.
The rule also ships a pin check across requirements*.txt,
pyproject.toml, poetry.lock, Pipfile.lock, and uv.lock for
langchain-text-splitters < 1.1.2.
What it does NOT catch
- Two-statement validate/fetch where the URL flows through an intermediate variable that is not the first argument to the fetch. Use AAK-SSRF-TOCTOU-001 (sibling rule) for the DNS-rebind class shape that does not require redirect-following.
- Manual redirect handling that re-validates each hop. We currently
only check the kwargs at the fetch call site; if the caller manages
redirects in a loop with their own validator we cannot prove safety
without flow analysis. AAK reads no per-line suppression comment, so to
silence a false positive, list the file under
ignore-pathsin.agent-audit-kit.yml(or pass--ignore-paths).
Remediation
Disable redirects at the fetch call:
# Python — requests
response = requests.get(url, allow_redirects=False, timeout=5)
# Python — httpx
response = httpx.get(url, follow_redirects=False)
# Python — urllib
opener = urllib.request.build_opener(urllib.request.HTTPRedirectHandler())
opener.open(url) # or override redirect_request()
// TypeScript — fetch
const r = await fetch(url, { redirect: 'manual' });
// Node — got
const r = await got(url, { followRedirect: false });
// Node — axios
const r = await axios.get(url, { maxRedirects: 0 });
Or revalidate the URL on every redirect hop (tighter but more code).
For langchain-text-splitters, bump to >= 1.1.2.
Sister rule
AAK-SSRF-TOCTOU-001 covers the DNS-rebinding shape: validate-then-fetch-with-fresh-DNS-resolution (CVE-2026-41488).
Registry reference
This section is generated from the rule registry (agent_audit_kit/rules/builtin.py) when the documentation is built, so it follows the scanner. The rest of the page is hand-written; where the two disagree, the registry is what runs.
- Severity
- HIGH
- Category
- Transport Security (
transport-security) - Scanner
agent_audit_kit/scanners/ssrf_redirect.py- Auto-fixable
- No.
- SARIF name
LangchainSsrfRedirect
What it detects
A function calls a known SSRF guard helper (validate_safe_url, is_safe_url, validateSafeUrl, etc.) and then fetches the same URL via requests.get, httpx.get, urllib.request.urlopen, fetch, or similar without disabling redirects. The allow-list fires once on the initial URL, but requests follows 3xx by default — a redirect into http://169.254.169.254/..., http://localhost, or another blocked target bypasses the guard and pulls the response back into the calling context. CVE-2026-41481 is the in-tree example (langchain-text-splitters < 1.1.2). Same shape applies in any agent-tooling code that does validate→fetch without allow_redirects=False / follow_redirects=False / redirect: 'manual'.
How to fix
Disable redirect following on the fetch call: requests.get(url, allow_redirects=False), httpx.get(url, follow_redirects=False), fetch(url, { redirect: 'manual' }). Or revalidate the URL on every redirect hop. For langchain-text-splitters, bump to >= 1.1.2.
To confirm the finding is gone, report only this rule:
agent-audit-kit scan . --rules AAK-LANGCHAIN-SSRF-REDIR-001
Limitations
In Python it looks inside one function for a call to one of seven guard names (validate_safe_url, validate_url, is_safe_url, ensure_safe_url, check_safe_url, ssrf_guard, is_url_safe) followed by a fetch (get, post, put, delete, request, urlopen, fetch or send) that does not disable redirects. A guard under another name (assert_public_url), or a guard and a fetch in two separate, non-nested Python functions, is not matched. The version check judges a git reference or an archive by the release its tag or file name names, with releases compared on their first three numbers, so a pre-release of the fix (langchain-text-splitters==1.1.2rc1) reads as the fix; a git reference to a commit or a branch (any name holding a / but refs/tags/<tag>) states no version and is reported. Declarations of one install that no release satisfies together (langchain-text-splitters==1.1.2 beside langchain-text-splitters==1.1.1 in one requirements file) admit nothing and are not reported; pip refuses to install them too. A source file over 1 MB, a pyproject.toml that does not parse and a manifest over 2 MB are not read. A pyproject.toml with a key of more than 64 dotted parts, or holding an integer Python cannot convert (one past 4,300 digits), is refused and reported as AAK-INTERNAL-SCANNER-FAIL. A lockfile over 32 MiB is not read.
References
- CVE: CVE-2026-41481
- OWASP MCP Top 10: MCP05:2025 (Command Injection & Execution)
- OWASP Agentic Top 10: ASI02 (Tool Misuse and Exploitation)
- Adversa AI MCP Top 25 (AAK-defined ids): ADV-NETWORK-02
- Incidents and advisories: GHSA-fv5p-p927-qmxr
- CSA AI Controls Matrix (AICM): IVS-04, AIS-08