Skip to content

pnpr: resolver fetches against client-supplied registries are an SSRF primitive when exposed to untrusted clients #26

Closed

Description

@zkochan

Summary

pnpr's resolver endpoint (POST /v1/resolve, and POST /v1/verify-lockfile) resolves against the registries supplied in the client request (registry, namedRegistries) and performs server-side outbound HTTP GETs to URLs derived from those inputs. There is no allowlist or network-range restriction on those base URLs, so if the resolver surface is reachable by untrusted clients it is an SSRF primitive (probing internal hosts, cloud metadata endpoints, etc.).

Where

  • serve_resolve calls handle_resolve with no auth gate.
  • Resolver::config_for sets pacquet's config.registry / config.named_registries directly from request fields.
  • pacquet's npm resolver builds the metadata URL as <registry>/<encoded-pkg> and issues client.get(url) (pacquet/crates/resolving-npm-resolver).

Notes / context

  • This is the resolver's documented design — it intentionally resolves against the client's registries so the server uses the same source of truth as the client, and forwards the caller's credentials for private packages. So this is a hardening item, not a regression.
  • The feature-toggle work (registry/resolver surfaces) does not change resolution-fetch behavior; it only gates which surfaces are mounted. But the new resolver-only deployment shape makes it more likely the resolver is exposed as a standalone, internet-facing tier, which amplifies the impact — hence filing this.

Possible mitigations to consider

  • An outbound registry allowlist (config: permitted registry hosts/URLs); reject requests whose registry/namedRegistries fall outside it.
  • SSRF range-blocking: refuse resolution against private/loopback/link-local IP ranges (and cloud metadata IPs) unless explicitly allowed.
  • Auth-gating the resolver surface (require an Authorization accepted by pnpr's gate before resolving), so it isn't anonymously reachable.
  • Documentation: make clear that a publicly-exposed resolver tier should sit behind an authenticating proxy / network policy.

Written by an agent (Claude Code, claude-opus-4-8).

Activity

  1. NeikiDev commented on Sep 25, 2026

    @NeikiDev

    I checked this against current main (41f2fd6). The SSRF vector described here looks closed by pnpm/pnpm#12700 (merged 2026-06-28), which added a default-deny fetch allowlist to the resolver.

    • reject_off_allowlist_fetches (pnpr/crates/pnpr/src/resolver/request_validation.rs) runs before any server-side fetch. It rejects with 403 a request whose registry, direct-URL dependency spec, catalog or package-extension entry, override leaf, or input-lockfile tarball URL points at an origin the operator has not configured. That covers http, every git transport and scp-style git remotes.
    • A declared scope registry that a resolve actually reaches is refused at fetch time by RouteHook::allows_fetch.
    • The resolver's HTTP client re-checks every redirect hop against the same allowlist, so an allowlisted registry cannot redirect to an internal host.

    Tests I ran on main, all passing:

    • pnpr-route: allows_registry_is_a_default_deny_allowlist, custom_registry_is_off_allowlist_until_declared_public, and 3 others.
    • pnpr: reject_off_allowlist_fetches_blocks_unconfigured_hosts (a request with registry: http://169.254.169.254/ is rejected) and reject_off_allowlist_fetches_scans_catalogs.

    What this does not cover: transitive dependencies with off-allowlist URLs, and DNS rebinding. Both are tracked in pnpm/pnpm#12705. Auth-gating the resolver surface and the deployment docs from the mitigation list were not done, if you still want those.

    I suggest closing this in favor of pnpm/pnpm#12705.


    Written by an agent (Claude Code, claude-opus-5-5).

  2. transferred this issue frompnpm/pnpmon Sep 26, 2026
  3. zkochan commented on Nov 8, 2026

    @zkochan
    MemberAuthor

    pnpm/pnpm#12700 added the allowlist (resolver/request_validation.rs) and pnpm/pnpm#15708 added a connect-time internal-address guard.

    Written by an agent (Claude Code, claude-opus-5-5).

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions