Skip to content

Check resolver download URLs with safehttp's address policy - #117

Merged
andrew merged 1 commit into
git-pkgs:mainfrom
simonchrz:fix/resolver-address-policy
Oct 24, 2026
Merged

andrew merged 1 commit into
git-pkgs:mainfrom
simonchrz:fix/resolver-address-policy

Conversation

@simonchrz

Copy link
Copy Markdown
Contributor

Closes #112.

checkMetadataURL had its own private-address check: it looked only at the first address the host resolved to, didn't block CGNAT, unspecified or multicast addresses, and had no way to allow anything. It now checks every address with safehttp.HostIPChecker.

fetch.WithAddressPolicy(opts safehttp.Options) gives the resolver the same options as the client that downloads the URLs, so the two agree. Without it the resolver uses safehttp's strict default. The https requirement and the empty-host check stay as they are. A host that doesn't resolve is still left to fail at download.

The fetch tests run with safehttp.EnableLoopbackForTesting, so loopback and private addresses pass the checker there. TestCheckMetadataURL now uses addresses safehttp always blocks (link-local, 0.0.0.0, multicast) instead of 127.0.0.1 and ::1, and TestWithAddressPolicy checks that the resolver keeps the policy it's given. safehttp's own tests cover loopback and private addresses.

checkMetadataURL had its own private-address check that looked only at
the first resolved address and missed CGNAT, unspecified and multicast
addresses. It now checks every address with safehttp.HostIPChecker.
WithAddressPolicy passes the safehttp.Options of the downloading client,
so callers can allow the hosts that client allows.
@andrew
andrew merged commit f2a9078 into git-pkgs:main Oct 24, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fetch.Resolver: let callers allow private hosts for download URLs

2 participants