Repository navigation
Description
Summary
ValidateRemoteURL (cmd/thv-operator/pkg/validation/url_validation.go) blocks internal/private endpoints by matching the parsed hostname against a CIDR list (when net.ParseIP succeeds) or a hostname blocklist (otherwise). Several host forms fall through net.ParseIP into the hostname path and match nothing there, bypassing the blocklist entirely. All of these are pre-existing and independent of the new allowPrivateEndpoint flag (#5784 / #6195) — they are accepted in both flag states:
| Form | Example | Why it slips through |
|---|---|---|
| Empty hostname | http://:8080/ |
u.Host is ":8080" (non-empty, passes the host check) but u.Hostname() is "", which matches no blocklist entry. Go's HTTP client dials loopback for an empty host. |
| Trailing dot (FQDN root) | http://localhost./ |
"localhost." fails the exact match against "localhost" and the "."+blocked suffix match; resolvers treat it as localhost. Applies to every blocked name (metadata.google.internal., etc.). |
| IPv6 zone ID | http://[fe80::1%25eth0]/ |
net.ParseIP rejects zone IDs, so a link-local literal drops into the hostname path and is never checked against fe80::/10. |
| Non-standard IP forms | http://2130706433/, http://0177.0.0.1/ |
Decimal/octal forms fail net.ParseIP and match no blocked hostname; whether they reach loopback depends on the consuming HTTP stack/resolver. |
These were identified during the review of #6195 and deliberately not fixed there: that PR's contract was flag-off behavior byte-for-byte identical to main, and closing these holes changes validation outcomes in both flag states, so it warrants its own change and test matrix.
Suggested direction
- Reject an empty
u.Hostname()explicitly (the currentu.Host == ""check does not coverhttp://:port). - Normalize (or reject) a single trailing dot before blocklist matching.
- Parse host literals with
netip.ParseAddr, which accepts zone IDs — check the address part against the CIDR sets, or reject zoned literals outright. - Consider rejecting any host that is neither a valid DNS name nor an address
netip.ParseAddraccepts — a shape allowlist also disposes of the decimal/octal forms without enumerating them.
Unit tests should cover each form in both AllowPrivateEndpoint states (all should be rejected in both).
Context: validateHostNotInternal and the blocklists live in cmd/thv-operator/pkg/validation/url_validation.go; the validator intentionally performs no DNS resolution, and nothing here requires adding any.
Activity
reyortiz3 commentedon Aug 17, 2026
Thanks for the thorough writeup, @premctl — and for catching these while working on #6195. The four forms you've laid out (empty host, trailing-dot FQDN, IPv6 zone ID, and decimal/octal literals) all look like real gaps in
validateHostNotInternal, independent of theallowPrivateEndpointflag.Given your context from #6195, would you be interested in sending a PR for this? Your suggested direction sounds right to us: explicit empty-
Hostname()rejection, trailing-dot normalization,netip.ParseAddrfor zone-ID-aware literals, and a shape check to catch non-standard IP forms. If so, please cover all four forms in bothAllowPrivateEndpointstates in the test matrix. Happy to give early feedback on approach before you go deep — and if you'd rather we take it, just let us know and we'll pick it up.premctl commentedon Aug 19, 2026
Thanks @reyortiz3 — happy to take it. Two things before I go deep: one ordering point, one design question.
Ordering vs #6195
#6195 is approved and green but not merged yet. The matrix you're asking for needs
ValidateRemoteURLOptionsfrom that PR — onmaintodayValidateRemoteURLstill takes a single argument, so there aren't two flag states to matrix over. Either:main— cleanest, and my preference; orEither works; let me know which you'd rather review.
Design question: how wide should the shape check be?
Three of the four have an obvious narrow fix and I'd just write them:
u.Hostname() == ""rejection alongside the existingu.Host == ""check.netip.ParseAddrand match the address part against the CIDR sets.fe80::/10is inalwaysBlockedCIDRspost-Allow opt-in private endpoints for remote URLs #6195, so[fe80::1%25eth0]is rejected in both flag states.http://backend.ns.svc.cluster.local./mcpis an ordinary resolver-emitted form and should be allowed whenAllowPrivateEndpointis on, not rejected. So: normalize, then the existing flag semantics apply unchanged.The fourth is the one I'd like your call on:
(a) Shape allowlist — reject any host that is neither accepted by
netip.ParseAddrnor a syntactically valid DNS name. Disposes of2130706433and0177.0.0.1without enumerating numeric encodings, and closes the rest of that family pre-emptively. Cost: it rejects hosts that work today and that nobody reported — most concretely, labels containing underscores (my_service.internal), which are RFC 1123-invalid but common in internal DNS.(b) Narrow — reject only hosts that are entirely numeric or dotted-numeric but fail
netip.ParseAddr. Kills the two reported forms, touches nothing else.I lean (a), with underscores explicitly permitted so the common internal-DNS case survives — it's the version that doesn't need revisiting the next time someone finds a novel encoding. But (a) is the only piece here with a blast radius outside the reported bug, so it's your call rather than mine; happy to go (b) if you'd rather keep this strictly to the reported forms.
Test matrix
All four forms × both
AllowPrivateEndpointstates, all rejected — each bottoms out inalwaysBlockedCIDRs/alwaysBlockedHostnames(localhost,127.0.0.0/8,fe80::/10), so the flag relaxes none of them. Plus a fifth row for the positive trailing-dot case above:backend.ns.svc.cluster.local.allowed with the flag on, rejected with it off.One caveat carried over from the issue: whether
2130706433actually reaches loopback is resolver-dependent — Go's pure-Go resolver won't take it, glibc'sinet_atonpath will. I'm treating it as defense-in-depth rather than a confirmed reachable SSRF, and the tests will assert validator behavior, not reachability.reyortiz3 commentedon Aug 21, 2026
Hi @premctl !, sorry it took a bit longer.
blkt commentedon Aug 24, 2026
@premctl I'm assigning this to you for tracking, just tidying up the board. Please let us know if this is a problem and you don't plan to work on this anymore.
reyortiz3 commentedon Aug 26, 2026
Hi @premctl , thanks again for submitting this issue to help improving Toolhive , much appreciated 🙏 !
Our Head of Product @Derek2Tu would like to chat with you. If you're ok (totally optional), I can have Will from the client engagement team help set that up.