Repository navigation
feat(plugins): allow private network hosts for paca.fetch - #693
Conversation
Self-hosted services on the same LAN or VPN as Paca can't be used by
plugins, because paca.fetch rejects every private address. Add
PLUGIN_FETCH_PRIVATE_HOSTS, an operator opt-in listing exact hostnames.
A private address is reachable only if the host is listed, the plugin's
manifest names it ("*" does not count), the URL is https, and the address
is RFC 1918 or fc00::/7. Loopback, link-local, metadata, CGNAT and IPv6
transition addresses stay blocked. The dial stays pinned to the checked
IP, and only the paca.fetch client gets the exception.
Redirects are held to the same conditions, since neither the URL check
nor the dialer would otherwise see them.
Refs Paca-AI#656
Co-Authored-By: Claude Opus 5.5 <[email protected]>
net/http maps a non-ASCII host through IDNA before dialing, so a redirect to "gitlab.internal" (fullwidth) or "gitlab.internal" (soft hyphen) dials "gitlab.internal". The redirect guard compared the raw name, so a public server could send a wildcard plugin to a listed private host, over http as well. Add netguard.CanonicalHost, which applies the same idna.Lookup profile as the transport and lowercases. PrivateHosts.Contains, the manifest match, the direct request check and the redirect guard all use it, and a name with no ASCII form is refused. PLUGIN_FETCH_PRIVATE_HOSTS now also rejects, with the startup warning, entries with a leading or trailing dot and non-ASCII entries, which could never match. International names must be listed in punycode. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Redirects to hosts outside the private host list follow the existing policy: they need not be in the manifest and may use http, and only the dial-time address check applies. Also list the entry forms that PLUGIN_FETCH_PRIVATE_HOSTS ignores and the IDNA comparison. Co-Authored-By: Claude Opus 5.5 <[email protected]>
It still said origins from when the function only parsed CORS origins. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
ℹ️ No critical issues — the security design holds up. One defense-in-depth note inline.
Reviewed changes
PLUGIN_FETCH_PRIVATE_HOSTSopt-in:netguard.PrivateHostsgetsNewPrivateHosts/CanonicalHost/Contains/Blocks, gating private addresses to exact listed hostnames that are also named in the manifest and served over https.- Dial pinning preserved:
guardedDialerunifiesSafeDialContextand the newNewSafeHTTPClientWithPrivateHosts; only thepaca.fetchclient receives the set, so marketplace/installer/email/Jev/automation keep the strict guard. - Redirect guard:
withPrivateHostRedirectGuardre-applies the https + manifest conditions to redirects into listed hosts, sinceCheckRedirectis the only per-request hook the shared transport offers. - Config + deploy:
Plugins.FetchPrivateHostsvia the renamedparseCommaList, wired inbootstrap/app.gowith startup warnings; Compose, Helm, docs and env examples updated;golang.org/x/netpromoted foridna. - IDNA normalization:
CanonicalHostmirrors net/http'sidnaASCII(ASCII short-circuit, thenidna.Lookup.ToASCII), so IDN spellings of a listed name cannot slip past the check.
I also verified the vectors the exception must not open: IP-literal/wildcard/host:port entries are refused by NewPrivateHosts; loopback, link-local/cloud metadata, CGNAT, unspecified, multicast and IPv6 transition literals stay blocked because Blocks requires ip.IsPrivate(); the Host header is already stripped from allowed fetch headers; and the Blocks decision is applied at both the URL check and the pinned dial. go test ./internal/platform/netguard/... ./internal/platform/plugin/... ./internal/config/... passes.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
| return false | ||
| } | ||
| if !namedInManifest { | ||
| privateHosts = nil |
There was a problem hiding this comment.
The manifest-naming condition is enforced only here. The transport dialer is built from the full operator set and has no plugin context, so this line is the sole gate for a "*"-manifest plugin — and it only holds if the pre-check's DNS answer matches the dial's. If the lookup here returns a public address while guardedDialer.dialContext re-resolves to a private one (TTL-0 rebinding), a wildcard plugin reaches the listed private host that privateHosts = nil was meant to deny. This is the same class the redirect guard closes for redirects, left open for the initial dial; it requires control of the listed name's DNS, which the docs already warn against trusting, so the practical impact is low.
Technical details
# Manifest-naming condition not enforced at dial time
## Affected sites
- `services/api/internal/platform/plugin/runtime.go:2322-2324` — `privateHosts = nil` grants the exception only for this pre-check; the dialer retains the full set.
- `services/api/internal/platform/netguard/netguard.go:199-203` — the transport dialer is constructed from the full operator set and cannot see `allowedOutboundDomains`.
- `services/api/internal/platform/plugin/runtime.go:2326` — pre-check resolves via `fetchLookupIPAddr`; the dial resolves again via `net.Resolver`, so the two answers can differ.
## Required outcome
- A request from a `"*"`-manifest plugin must not reach a listed private host unless the dial-time decision also reflects that the manifest does not name the host.
## Suggested approach (optional)
- The transport is shared across plugins, so this needs per-request plumbing (e.g. a per-plugin client/transport, or a dialer that consults a request-scoped allow decision) rather than a change in `Blocks`. If threading this through is out of scope, documenting it as a known limitation alongside the proxy/header follow-ups is reasonable.There was a problem hiding this comment.
Fixed in a931328: paca.fetch now passes the hosts the manifest names in the request context, and the shared dialer grants the exception only to hosts in both that set and the operator list (no context, no exception). Covered by TestGuardedDial_RequiresPerRequestAllowance and TestManifestPrivateHosts.
pikann
left a comment
There was a problem hiding this comment.
LGTM! Thank you for the contribution! 🚀
…r-plugin Resolves the add/add conflict in services/api/internal/platform/plugin/runtime_fetch_test.go: master's file (private-network host and redirect guard tests, #693) is kept as is, and the chunked-fetch tests move to runtime_fetch_chunk_test.go. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…r-plugin Resolves the add/add conflict in services/api/internal/platform/plugin/runtime_fetch_test.go: master's file (private-network host and redirect guard tests, #693) is kept as is, and the chunked-fetch tests move to runtime_fetch_chunk_test.go.

Refs #656 (item 2).
paca.fetchrejects every private address, so a plugin can't reach a self-hosted GitLab on the same LAN or VPN as Paca, even when the host is in the manifest. This addsPLUGIN_FETCH_PRIVATE_HOSTS, the operator opt-in discussed in the issue. It's empty by default, and an empty list behaves as before.Behaviour
A request may reach a private address only if all of these hold:
PLUGIN_FETCH_PRIVATE_HOSTS(exact, case-insensitive, compared in the IDNA form that is dialed).allowedOutboundDomains.https.10.0.0.0/8,172.16.0.0/12,192.168.0.0/16orfc00::/7.The dial stays pinned to the checked IP, so the rebinding protection from GHSA-cj3q-c44j-q8p9 still applies. Only the
paca.fetchclient gets the exception:SafeDialContext,NewSafeHTTPClientandNewSafeHTTPTransportare unchanged, so marketplace, installer, email, Jev and automation clients behave as before.Decisions to review
"*"does not count as naming a host. Plugins using"*"call user-supplied URLs, so it could otherwise let any project user aim a webhook-style plugin at an internal host.paca.fetchclient is shared by all plugins, sopaca.fetchputs the hosts the manifest names into the request context (netguard.WithAllowedPrivateHosts), and the dialer grants the exception only to hosts in both that set and the operator's. A request without it gets no exception. Without this, a"*"plugin was kept off a listed host by the pre-check alone, which a DNS answer changing before the dial could bypass.https); the dialer enforces the manifest part as well, the redirect check addshttpsand a clearer error. Redirects to other hosts follow the existing policy: public targets are allowed, even outside the manifest and overhttp.idna.Lookup, the profilenet/httpuses before dialing) everywhere they are compared, sogitlab.internalcan't slip past a check ongitlab.internal. Names with no ASCII form are refused.100.64.0.0/10) stays blocked. Some cloud metadata endpoints live there, asnetguardalready notes. This means Tailscale addresses aren't reachable; tracked in Plugin fetch: allow CGNAT addresses (Tailscale) for listed private hosts? #688.::ffff:mapped addresses are treated as their IPv4 form.host:port, leading or trailing dot, non-ASCII: list IDNs in punycode). The API still starts. A warning also lists the active hosts.gitlab.comonly, and there is no override). That edit is lost when the plugin is updated.parseCORSOriginsis renamed toparseCommaList, since it now has a second use.Testing
go vet ./...,go test ./...(3356 tests in 59 packages) andgolangci-lintv2.15 (0 issues) pass. New unit tests cover the IP rules, including embedded IPv4 forms, the pinned dial, DNS changing between dials, manifest matching (also at dial time), redirects, IDN spellings (fullwidth, soft hyphen;httpsandhttp, also through the realnet/httptransport) and the empty list.10.77.0.0/24), behind Caddy with an internal CA, usingcom.paca.gitlabwith the host added to a temporary copy of its manifest:gitlab.internalresolves to10.77.0.2010.77.0.20gitlab.comonly10.77.0.20"*"10.77.0.20127.0.0.1169.254.169.254The Helm chart renders with
helm template(the variable is empty unlessfetchPrivateHostsis set). Redirects, rebinding and the IDN fix are covered by unit tests only, not against the real GitLab.Docs and deploy
Adds the variable to
docker-compose.prod.ymland the Helm chart (api.plugins.fetchPrivateHosts), both of which list API variables explicitly. Documented indocs/plugins/backend-plugin-system.md, including the security implications, plusdeploy/README.mdand the env examples.Possible follow-ups (pre-existing, not changed here)
HTTPS_PROXYset, the dialer checks the proxy, not the destination.PRIVATE-TOKENare forwarded on cross-host redirects.🤖 Generated with Claude Code