fix: ensure cloud metadata SSRF error is consistent for IPv4-mapped addresses

This commit is contained in:
GitHub Actions
2026-03-18 17:23:53 +00:00
parent fcc9309f2e
commit 3099d74b28
@@ -294,6 +294,11 @@ func ValidateExternalURL(rawURL string, options ...ValidationOption) (string, er
continue
}
if network.IsPrivateIP(ipv4) {
// Cloud metadata endpoint must produce the specific error even
// when the address arrives as an IPv4-mapped IPv6 value.
if ipv4.String() == "169.254.169.254" {
return "", fmt.Errorf("access to cloud metadata endpoints is blocked for security (detected: %s)", sanitizeIPForError(ipv4.String()))
}
return "", fmt.Errorf("connection to private ip addresses is blocked for security (detected IPv4-mapped IPv6: %s)", ip.String())
}
}