AAK-SSRF-002: Localhost/loopback reachable from MCP tool
- Severity
- HIGH
- Category
- MCP Configuration (
mcp-config) - Scanner
agent_audit_kit/scanners/ssrf_patterns.py- Auto-fixable
- No.
- SARIF name
SsrfLoopbackReachable
What it detects
An MCP tool handler forwards user-supplied URLs that could target 127.0.0.1/localhost/::1, reaching internal services bound to loopback.
How to fix
Take the loopback or private address out of the outbound call's URL: use the real public host, or read the target from configuration. The rule matches localhost and names under .localhost, 127.0.0.1, 0.0.0.0, ::1, 10.x, 172.16.x to 172.31.x and 192.168.x, also in a URL that writes the address another way (http://2130706433/ is 127.0.0.1) or in a wildcard-DNS name that embeds it (10-0-0-5.nip.io, localtest.me). Where the URL can also come from the caller, resolve the host and refuse loopback, private and link-local results before connecting.
To confirm the finding is gone, report only this rule:
agent-audit-kit scan . --rules AAK-SSRF-002
Limitations
Reads only files that contain @tool, createTool, McpServer, FastMCP, mcp.tool, Server.run_streamable_http, BaseTool or StructuredTool, or def forward and output_type with a class on a Tool base (a smolagents tool). It reads each string that reaches a recognised fetch call as a URL and reports a host of localhost, 127.0.0.1, ::1, 0.0.0.0 or a 10.x, 172.16-31.x or 192.168.x address, in any spelling a client reads as one (http://2130706433/, http://0x7f.1/), or a wildcard-DNS name embedding one: the dot, dash, hex and IPv6 forms under nip.io and sslip.io, the dot and dash forms under xip.io, and localtest.me and lvh.me. A name that resolves there with nothing in the name to say so (a rebinding service, your own domain) needs a lookup, which a scan does not do. In Python a string reaches the call through up to four names (base = a, a = b, b = c, c = "http://10.0.0.5"), each looked up across the whole file rather than in the call's own function, so a base another function binds is read as the handler's, and only through = and annotated = bindings, so an address a for loop, +=, := or tuple unpacking (base, port = ...) binds is missed. A string with no scheme counts only when it starts with such a host written out (127.0.0.1:8080, [::1]), so a host assembled from pieces, as in "http://" + HOST with HOST = "2130706433", is missed. Other loopback and private addresses (127.0.0.2, an IPv6 unique-local address such as [fd12:3456::7]) are not matched, and a file gets one finding, for the first matching call (in ast.walk order in Python), so a loopback fetch that follows a metadata fetch is reported as AAK-SSRF-003 alone.
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-02 (Tool Param SSRF)
- CSA AI Controls Matrix (AICM): IVS-04
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-002.md: the page then shows that text, with the registry reference appended under it.