You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SSRF guards bypassed by non-canonical IP literals the dialer accepts but net.ParseIP rejects (all four guard sites) #2425
All four SSRF guards in the registry client decide "is this an IP literal" with net.ParseIP(host), which accepts only canonical dotted-quad IPv4 and canonical IPv6. Go's dialer (hence net/http) accepts many more forms, so for those hosts the guards' private/loopback/link-local rejection never executes while the request is still delivered to the private address:
Form
Example
Resolves to
32-bit decimal
2130706433
127.0.0.1
decimal (metadata)
2852039166
169.254.169.254
hex integer
0x7f000001
127.0.0.1
partial dotted-quad
127.1
127.0.0.1
zero-padded octets
127.000.000.001
127.0.0.1
zone-qualified IPv6
[fe80::1%25eth0]
link-local
Affected guards
validateRealmURL — pkg/v1/remote/transport/bearer.go:154 (WWW-Authenticate realm; the comment states it blocks "loopback, and link-local ranges including the cloud instance metadata service")
checkRedirectSSRF — pkg/v1/remote/fetcher.go:101 (3xx redirect targets during manifest/blob GET)
validateForeignURL — pkg/v1/remote/fetcher.go:383 (foreign-layer urls[] from a manifest)
Evil registry answers /v2/ with WWW-Authenticate: Bearer realm="http://2130706433:PORT/token". The library fetches the token from that realm sending the victim's Basic credentials — observed Authorization: Basic dmljdGltOlN1cGVyU2VzZWNyZXQxMjM arriving at the collector. Control: the identical dotted-quad realm is correctly rejected (realm host "127.0.0.1" is a private or link-local address). Separately observed: realm host 2852039166 passes the guard and the library dials 169.254.169.254.
Reproduction test module in the fix PR description.
Why this is a bug, not intended
The guards' comments claim exactly this coverage; these are IP literals, not the documented-out-of-scope DNS case.
Normalize the host before the check: strip any IPv6 zone, then parse with netip.ParseAddr; additionally handle the legacy inet_aton forms (or resolve and re-check all resulting IPs). Apply uniformly in all four guards.
Reported via Google Bug Hunters (acknowledged; public disclosure invited).
Activity