Skip to main content

Module url_guard

Module url_guard 

Source
Expand description

Refusing URLs that point into the server’s own network (SSRF).

Spec §14: “File references within A2A messages MUST be validated to prevent SSRF”. The SDK never fetches a file reference itself; the agent does. These are the checks the push sender has applied to webhook URLs since 0.3, made public on 2026-10-18 so an agent can apply them before it fetches anything a caller named, and used by RequestHandlerBuilder::refuse_private_file_urls to refuse such a message on arrival.

check_public_url needs no I/O: scheme http/https, and a host that is not a private, loopback, link-local, unspecified or CGNAT address (including IPv4 smuggled in IPv6, and the numeric forms inet_aton accepts), nor localhost, *.local or *.internal. resolve_public_url also resolves a host name and checks every address it resolves to, and returns one to connect to (resolve_public_addrs returns all of them): connecting to those addresses, not the name, is what stops a rebinding resolver from answering differently the second time.

Functions§

check_public_url
Refuses url unless it points outside the server’s own network.
resolve_public_addrs
resolve_public_url, returning every address the host resolved to.
resolve_public_url
check_public_url, then the same check on every resolved address.