fix(arborist): recognize registry-mediated tarballs - #9921
Open
martinrrm wants to merge 4 commits into
Open
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
martinrrm
commented
Aug 27, 2026
| }) | ||
|
|
||
| t.test('allowRemote=none blocks same-origin tarball outside registry path', async t => { | ||
| t.test('allowRemote=none allows registry-advertised tarball outside registry path', async t => { |
Contributor
Author
There was a problem hiding this comment.
This test for the main change to fix #9796.
If a registry is serving tarballs from a different path than the actual registry metadata (such as https://registry.example.com/blob/package.tgz, while the registry is https://registry.example.com/npm) this results in EALLOWREMOTE attempting to install anything from it.
martinrrm
commented
Aug 27, 2026
| await t.resolves(arb.reify(), 'registry-advertised sibling-path tarball is allowed') | ||
| }) | ||
|
|
||
| t.test('allowRemote=none verifies against dependency identity, not lockfile name', async t => { |
Contributor
Author
There was a problem hiding this comment.
This test is also important; we are now getting the packument of the package (so a new metadata request if the tarball URL is different from the registry) and validating that the advertised URL are the same.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
npm:aliases use the target package's scope, registry, and credentialsallow-remotepolicy behavior and carry trusted identity through the linked install strategyProblem
During reification, Arborist passes registry tarballs to pacote as
name@URL.npm-package-argparses that temporary spec as a remote dependency, so Arborist grants a narrowallowRemote: 'all'exemption after confirming the URL came from a configured registry.The existing confirmation had two blind spots:
hoek: npm:@npm/hoek@6.1.4, that loses the target scope and selects the default registry instead of the registry configured for@npm.Both cases incorrectly reached pacote's remote-fetch policy and failed with
EALLOWREMOTEunder npm 12's defaultallow-remote=none.Implementation
Registry tarballs under the configured registry path retain the existing fast-path exemption. For a same-origin URL outside that path, Arborist now fetches the exact package-version manifest and grants the exemption only when its advertised tarball URL matches the effective lockfile URL. Registry-host replacement is applied consistently, URL fragments are ignored because they are not sent over HTTP, and path and query components must still match exactly.
The package identity used for this verification is derived from valid inbound dependency specs rather than package or lockfile metadata.
npm:aliases are unwrapped to their target package names, and all valid inbound registry edges must agree. This identity is also used for the temporary pacote extraction spec so scoped registry authentication follows the alias target while the package remains installed in its alias location. Linked installations explicitly carry the trusted identity to their synthetic store nodes.Verification fails closed: metadata errors, mismatches, conflicting dependency identities, cross-origin URLs, and non-registry dependencies continue through the configured
allow-remotepolicy and remain blocked when that policy isnone. Arborist also skips metadata verification when remote fetching is already permitted by implicit or explicitall, or for a root dependency underroot.Tests
npm ciregression proving an unadvertised same-origin sibling-path tarball remains blockedFixes #9796