Repository navigation
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>
| }) | ||
|
|
||
| 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 => { |
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.
| 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 => { |
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.
Validate locked versions, preserve root-selected aliases for ordinary consumers, and reuse registry URL evidence with coalesced abbreviated metadata requests. Keep explicit signature and attestation verification separate from captured URL evidence. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Registry verification is not bound to the locked integrity used for extraction, allowing signatures or attestations for one digest to authorize extraction of different package bytes.
3 open issues
What changed in this PR
This PR addresses #9796 by allowing Arborist to recognize registry-advertised tarballs served from same-origin sibling paths without trusting arbitrary lockfile URLs.
Changes:
- Verifies sibling-path URLs against exact-version registry metadata, with cache reuse and shared pending requests.
- Preserves alias target identity and scoped authentication during reification and linked installs.
- Adds regression coverage and documents cold-cache and offline metadata requirements.
| File | Description |
|---|---|
workspaces/config/lib/definitions/definitions.js |
Documents sibling-path verification and offline requirements. |
workspaces/arborist/test/registry-tarball.js |
Tests metadata evidence, caching, exact versions, and verification. |
workspaces/arborist/test/registry-package-name.js |
Tests trusted identity selection and propagation. |
workspaces/arborist/test/arborist/reify.js |
Adds registry-tarball and alias integration coverage. |
workspaces/arborist/lib/registry-tarball.js |
Adds registry evidence lookup and caching. |
workspaces/arborist/lib/registry-package-name.js |
Derives trusted package identities from dependency edges. |
workspaces/arborist/lib/arborist/reify.js |
Applies URL exemptions and alias-aware extraction identity. |
workspaces/arborist/lib/arborist/isolated-reifier.js |
Carries trusted identities through linked-install transformations. |
workspaces/arborist/lib/arborist/build-ideal-tree.js |
Captures registry URL evidence during resolution. |
test/lib/commands/ci.js |
Adds tampered-lockfile regression coverage. |
tap-snapshots/test/lib/docs.js.test.cjs |
Updates the configuration documentation snapshot. |
Review effort: Balanced
retain verified integrity in cache, validate every lock entry and use the verified digest for extraction; preserve the raw-spec identity for conditional override fallbacks; select exact build-qualified manifests while retaining pacote verification. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9aefcaed-984b-40a9-b82a-57d80f4f8fee


Summary
Problem
During reification, Arborist passes registry tarballs to pacote as
name@URL. npm-package-arg parses that temporary spec as a remote dependency, so Arborist needs a narrow exemption for registry-mediated tarballs.The existing classifier only recognized tarball paths beneath the configured registry path. Private registries can legitimately advertise tarballs from another path on the same origin. It also selected registries using the installed dependency slot: for
hoek: npm:@npm/hoek@6.1.4, that loses the target scope and can select the wrong registry or credentials. Both cases can incorrectly fail with EALLOWREMOTE under the npm 12 defaultallow-remote=none.Implementation
Package identity and compatibility
Identity comes from valid dependency specifications, not package/lockfile name fields. Aliases are unwrapped to target names. Ordinary peers constrain the installed slot rather than redefining an alias target. Project/workspace selections also take precedence over ordinary compatible transitive requirements, while disagreeing explicit alias targets remain rejected. A transitive alias cannot supersede a plain root selection.
Linked installs carry this identity through intermediate proxies and synthetic store nodes. Extraction uses the target identity independently of remote-permission mode, so authentication follows the target scope while the install location remains the alias slot.
Sibling-path verification
The configured-registry-path fast path remains. A same-origin URL outside that path is permitted only when registry evidence for the trusted package and exact version advertises the same effective tarball URL.
Locked versions must be exact semantic versions; aliases, ranges, tags, URLs, and other dependency specifications in that field cannot redirect verification. Metadata names and versions must match. Host replacement is applied consistently to both URLs. Fragments are ignored; the remaining URL, including path and query, must match.
Metadata reuse and request behavior
Cold locked sibling-path installs can still require metadata requests. A cached tarball alone does not establish the additional evidence needed for an offline sibling-path install. This is an intentional availability/performance tradeoff, not a promise of zero additional requests.
Policy boundaries
Already-permitted implicit/explicit
all, and root-direct requests underroot, skip URL verification. Metadata failures, mismatches, unverifiable identities, and cross-origin URLs do not grant an exemption. Explicit remote dependencies remain governed by the configured policy. Extraction continues to receive the locked integrity value.Regression coverage
Fixes #9796