Skip to content

safehttp: per-host private-address allowlist #67

Description

@andrew

fetch.WithAllowPrivateHosts (added in #51, released in v0.7.0) stores an allowlist that only the fetcher's default DialContext consults via gateOptions. When a caller passes fetch.WithHTTPClient, that default transport is replaced and the allowlist is never read.

git-pkgs/proxy builds its own safehttp.New(nil, safehttp.Options{}) client so it can wrap the transport with auth and access-log layers before passing it to fetch.NewFetcher(fetch.WithHTTPClient(...)). Under that composition there's no way to allowlist a private-network upstream: safehttp.Options only offers the blanket AllowPrivate / AllowLoopback booleans, and fetch.WithAllowPrivateHosts has no effect on an injected client. The metadata http.Client the proxy uses directly (outside the fetcher) has the same limitation.

Suggested change: add AllowPrivateHosts []string (matched via the existing normalizeHost) to safehttp.Options and have the safehttp DialContext apply AllowPrivate for those hosts only. fetch.WithAllowPrivateHosts can then set it on the default client's options rather than keeping a separate map, so both the default and injected-client paths behave the same.

Blocks git-pkgs/proxy#223.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions