Skip to content

AAK-SSRF-MAPPED-001: A URL guard tests an address against IPv4 networks, and IPv4-mapped IPv6 passes

Severity
HIGH
Category
Transport Security (transport-security)
Scanner
agent_audit_kit/scanners/ssrf_toctou.py
Auto-fixable
No.
SARIF name
SsrfGuardPassesMappedAddress

What it detects

A URL or host guard parses the host with ipaddress.ip_address and tests membership in a deny list of networks (ip in ip_network("169.254.0.0/16"), any(ip in n for n in BLOCKED)) without unwrapping .ipv4_mapped. http://[::ffff:169.254.169.254]/ parses as an IPv6 address, which is in no IPv4 network, so it passes, and a dual-stack socket connects to the metadata address. .is_private is not the same bug: it unwraps a mapped address on every CPython tried from 3.9.0 to 3.13.11, so a guard that also reads it does not fire.

How to fix

Unwrap before the test: on an IPv6 address, use its ipv4_mapped when that is set. Adding ::ffff:0:0/96 to the deny list or also testing .is_private closes it too. Add a test that http://[::ffff:169.254.169.254]/ is refused. Check the resolved address again at connect time, since a check at load cannot see a name that later resolves elsewhere.

To confirm the finding is gone, report only this rule:

agent-audit-kit scan . --rules AAK-SSRF-MAPPED-001

Limitations

Reads Python, one function at a time, in a file that mentions ip_network and one of ssrf, urlparse, urlsplit, .hostname or getaddrinfo. The test must be in on ip_address(...) or a name bound from it in that function, so an address passed in as a parameter, subnet_of and an integer range check are not read. A deny list is known by the name of the function or of the networks (private, block, deny, internal, metadata, link_local, loopback, reserved, ssrf, forbid, unsafe, disallow, banned, restricted) or a private ip_network(...) literal, so a list under another name is missed, and one named for allow, trust, scope, whitelist or permit fails closed on a mapped address and is left out. ipv4_mapped, IPv4Address, IPv6Address, .version, ::ffff, AF_INET or gethostbyname anywhere in the file stands the rule down, without checking that it guards this test. .is_private or .is_global in the function stands it down too: that closes the metadata and RFC 1918 cases and not ::ffff:100.64.0.1. A guard testing only .is_loopback or .is_link_local is not read, though older CPython patch releases do not unwrap those (3.12.3 for both, 3.13.0 for link-local). Whether the result gates a fetch is not read, so an IP filter that is no URL guard, in a file with one of those words, fires. A source file over 1 MB is not read.

References

  • 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-SSRF-01 (Internal Network MCP)

All rules. This page is generated from the rule registry when the documentation is built; to change it, change the rule in agent_audit_kit/rules/builtin.py. To give the rule a hand-written write-up, add docs/rules/AAK-SSRF-MAPPED-001.md: the page then shows that text, with the registry reference appended under it.