You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
recognize registry-mediated tarballs served from same-origin sibling paths without trusting arbitrary lockfile URLs
preserve alias target identity and scoped authentication for ordinary peers, root-selected aliases shared with ordinary dependencies, and linked installs
validate locked versions and use cache-first registry evidence with coalesced abbreviated metadata requests
keep requested signature/attestation verification separate from URL-only evidence
document cold-cache and offline requirements
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/[email protected], that loses the target scope and can select the wrong registry or credentials. Both cases can incorrectly fail with EALLOWREMOTE under the npm 12 default allow-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
Capture compact URL evidence from actual pacote manifest responses during resolution, never from serialized node/lockfile fields.
Reuse full or abbreviated packuments already present in the memory cache.
Request abbreviated metadata on a verification cache miss and inspect the exact version entry without treating the locked version as a dependency spec.
Share pending verification requests per registry/package across instances and versions. Retain compact URL evidence even when the production cache discards large responses or responses without Content-Length.
Keep offline requests offline. An abbreviated ENOTCACHED result permits an offline lookup of the full HTTP variant, accounting for Vary: Accept.
Treat captured evidence as URL-only regardless of verification flags during resolution. Explicit signature/attestation verification still uses the dedicated full-metadata path; abbreviated old-lock hydration cannot bypass it.
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 under root, 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
malformed locked-version specs, including an alias injected into a wildcard lockfile entry, without unauthorized metadata or tarball requests
The reason will be displayed to describe this comment to others. Learn more.
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.
The reason will be displayed to describe this comment to others. Learn more.
🟡 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.
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.
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 <[email protected]>
Copilot-Session: 9aefcaed-984b-40a9-b82a-57d80f4f8fee
Exact published build-qualified keys are retained for pacote identity validation; only the cleaned-version lookup is non-enumerable, and verified malformed metadata fails closed.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 9aefcaed-984b-40a9-b82a-57d80f4f8fee
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Linked-install deduplication omits trusted package identity, allowing a tampered lockfile to authorize one dependency using another dependency’s metadata.
Host replacement strips query parameters from verified URLs
workspaces/arborist/lib/arborist/reify.js:763
With replaceRegistryHost: 'always', extraction rewrites the already-normalized URL again through pacote's RemoteFetcher, which keeps only its pathname. A verified sibling-path URL such as https://r.example/blob/pkg.tgz?token=x therefore loses its query, breaking query-authenticated downloads and fetching a different URL from the one verified. Disable host replacement for the already-normalized exempted URL.
Accepted alias fallback misidentifies the package for registry selection
When a conditional alias override is satisfied only through acceptDependencies, passing edge.accept makes this check treat the override target as the package identity. With foo: '^1.0.0', override '[email protected]': 'npm:@scope/[email protected]', and accepted range '^2.0.0', ordinary locked [email protected] incorrectly uses @scope/foo's registry and credentials. Check the override without the acceptance fallback, derive identity from the original or accepted specification that applies, and add an accept-only alias regression.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Integrity matching can bypass the lockfile’s strongest digest and accept invalid bytes, while missing integrity on synthetic linked nodes triggers unnecessary extraction and lifecycle-script runs on repeat installs.
ssri.match() uses the strongest algorithm common to both sets, which may be weaker than the lockfile's strongest digest. For a lock containing a mismatched SHA-512 plus a matching SHA-1, and verified metadata containing only that SHA-1, this condition skips the stream check and subsequently replaces the locked integrity with SHA-1. Extraction then accepts bytes the original lock would reject. Compare each set's strongest algorithm and stream-check both sets when they differ; cover overlapping multi-algorithm values as well as the existing disjoint-algorithm cases.
Use strongest-algorithm checks and common digest-set intersection when preserving integrity constraints.
Streamed verification binds extraction to concrete calculated digests.
Synthetic actual linked entries retain integrity to avoid unnecessary extraction and lifecycle work.
Add regression coverage for these reification paths.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 9aefcaed-984b-40a9-b82a-57d80f4f8fee
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Store entries missing package.json can inherit the ideal version and integrity, causing subsequent installs to skip restoration of incomplete packages.
…0218)
## Summary
Narrow v10 adaptation of the alias identity/authentication correction in
#9921.
- Derive the extraction package name from valid dependency
specifications rather than the installed alias slot or
package-controlled metadata.
- Preserve scoped registry authentication for aliases shared with
ordinary dependencies, regular peers, and optional peers.
- Carry that identity through both linked-install transformations.
- Match v10's existing override semantics: bundled and shrinkwrapped
dependencies use the raw specification.
- Preserve the existing extraction fallback when the dependency identity
is absent, non-registry, or ambiguous.
## Backport scope
This targets `release/v10`. It is not a full cherry-pick of #9921, which
targets `latest` and is still open.
npm 10 does not have the newer `allow-remote` policy feature. This PR
therefore does not introduce remote-policy enforcement or exemptions,
sibling-path metadata verification, additional metadata requests,
configuration changes, dependency upgrades, or generated/bundled
dependency changes.
## Regression coverage
Nine mocked-registry integration scenarios cover hoisted and linked
installs, ordinary consumers, regular and optional peers, and global
alias installation. A token scoped to the registry's `/npm/` path must
accompany the sibling-path tarball request. Deliberately misleading
lockfile/package metadata cannot select the credential scope.
Identity tests cover aliases, peer and project/workspace precedence,
conflicting selections, non-registry specifications, linked
transformations, and v10 override/bundle/shrinkwrap behavior.
## Validation
- Before the fix, the eight original local/linked integration scenarios
fail because the tarball request lacks the expected scoped authorization
header.
- Final focused checks pass on Windows with Node 22.23.4: all nine
integration scenarios, all 26 identity assertions, and owning-package
ESLint.
- `git diff --check` passes.
- Full Arborist tests were attempted with coverage retained, but the
locally reused development tooling encounters Windows fixture/socket
errors and native Node crashes. The same `No socket was returned in the
connect() function` failure and native exit reproduce on the clean v10
base commit `a8804198f147914cab2fc25f6d48535f13621b9a`.
- Full-suite success/coverage and the supported Node/OS CI matrix are
not established locally.
- Template-oss postlint is blocked by the local tooling mismatch: v10
pins 4.29.0, while the reused checkout has 5.1.1. No generated files,
coverage settings, or dependencies were changed to bypass these checks.
Draft pending review and validation with the maintenance branch's
matching tooling/CI.
Copilot-Session: ede510fc-429c-4202-aac7-66584aaee157
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because findings omitted from the published review include a critical verification bypass alongside registry-policy and reinstall regressions.
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
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
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/[email protected], 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