Details
Threat model alignment
The maintainer's prior position on the SSRF class is captured by GHSA-6jxm-fv7w-rw5j (HTML Check, Medium), GHSA-mpf7-p9x7-96r3 (Link Check, Medium), and GHSA-8v65-47jx-7mfr (Proxy Endpoint, Medium). All three are siblings in the same SSRF class, and the maintainer chose to remediate each via a safeDialContext-style filter in the linkcheck and proxy fixes. The htmlcheck fix is the outlier: same class, same severity, but the IP filter was not applied. The remaining surface is therefore a regression of the published fix's stated goal ("disallow internal targets").
Default-deploy reachability is unauthenticated (per the maintainer's own README, mailpit is intended to run without auth in dev/CI). With UI auth configured, the same primitive is post-auth — still useful (UI-auth mailpit deployments often live on the internal/ops subnet, exposing other ops services).
Suggested fix
Make newSafeHTTPClient use the same safeDialContext pattern already proven in linkcheck/status.go and server/handlers/proxy.go. Concretely:
// internal/htmlcheck/css.go
func newSafeHTTPClient() *http.Client {
dialer := &net.Dialer{
Timeout: 5 * time.Second,
KeepAlive: 30 * time.Second,
}
tr := &http.Transport{
Proxy: nil,
DialContext: safeDialContext(dialer), // ← add IP filter
TLSHandshakeTimeout: 5 * time.Second,
ResponseHeaderTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
IdleConnTimeout: 30 * time.Second,
MaxIdleConns: 50,
}
client := &http.Client{
Transport: tr,
Timeout: 15 * time.Second,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
if len(via) >= 3 {
return errors.New("too many redirects")
}
if !isValidURL(req.URL.String()) {
return errors.New("invalid redirect URL")
}
// safeDialContext re-runs IP filter on each hop's Dial,
// so redirect target IP is also enforced.
return nil
},
}
return client
}
// safeDialContext is the same pattern as linkcheck/status.go::safeDialContext
// — copy the function (or factor a shared helper into internal/tools/net.go).
func safeDialContext(dialer *net.Dialer) func(ctx context.Context, network, address string) (net.Conn, error) {
return func(ctx context.Context, network, address string) (net.Conn, error) {
host, port, err := net.SplitHostPort(address)
if err != nil { return nil, err }
ips, err := net.DefaultResolver.LookupIPAddr(ctx, host)
if err != nil { return nil, err }
if !config.AllowInternalHTTPRequests {
for _, ip := range ips {
if tools.IsInternalIP(ip.IP) {
return nil, fmt.Errorf("blocked request to %s (%s): private/reserved address", host, ip)
}
}
}
return dialer.DialContext(ctx, network, net.JoinHostPort(ips[0].IP.String(), port))
}
}
Two further hardening notes:
- Add CGNAT 100.64.0.0/10 (RFC 6598).
tools.IsInternalIPcovers loopback, private, link-local, multicast, unspecified — but not CGNAT. This affects all three SSRF dialers (htmlcheck, linkcheck, proxy). Tailscale tailnets and GCP IAP fall in100.64.0.0/10; an mailpit instance running on a Tailscale node can be used to pivot into the tailnet. Concrete fix: extendtools.IsInternalIPwithcgnat := net.IPNet{IP: net.IPv4(100, 64, 0, 0), Mask: net.CIDRMask(10, 32)}; if cgnat.Contains(ip) { return true }. - Re-validate the rename.
newSafeHTTPClientis a misleading name today — once the dialer is hardened, the name will be accurate. Until then, consider renaming it tonewHTTPClientto remove the false sense of safety it conveys to maintainers reading the file.
Reproduction environment
- Tested against: HEAD
8bc966e61834a24c48b4465da418f75e73be0afd(2026-05-06). - Code locations:
- Vulnerable dialer:
internal/htmlcheck/css.go:275-310 - Vulnerable downloader:
internal/htmlcheck/css.go:192-229 - Reachability gate:
internal/htmlcheck/css.go:131-187(inlineRemoteCSS) - Trigger handler:
server/apiv1/other.go:18-79(HTMLCheck) - Default no-UI-auth:
internal/auth/auth.go+ middleware inserver/server.go:317 - Default no-SMTP-auth:
internal/smtpd/main.go:229-230 - Sister fixed dialers (for diff):
internal/linkcheck/status.go:140-163,server/handlers/proxy.go:393-415
Reporter
Eddie Ran. Filed via reporter API.