Repository navigation
Description
Summary
For Bun and pnpm 12+, a packageManager hash covers only the main tarball. The executable comes from a platform package (@oven/bun-<os>-<arch> or @pnpm/exe.<os>-<arch>), and vp checks it only against the registry dist.integrity of that package. When the platform version document has no dist.integrity, vp installs the executable without any check. The install goes into the .verified-v1 namespace, and later runs with the same pin and registry reuse it without a check.
Why the pin cannot cover the executable
The main tarballs contain only placeholders:
bun-1.2.0.tgz:package/bin/bun.exeis 0 bytes.postinstallrunsinstall.js.pnpm-12.21.0.tgz:package/pnpmis a 4 KBshscript. Its comment says "pnpm's native binary replaces this file during installation".
In these versions, package.json lists the platform packages by version only (11 for Bun, 15 for pnpm), with no hashes. All platforms share one packageManager value, so one hash cannot describe the different platform executables. The registry dist.integrity is the only check of the file that vp runs.
Code path
Bun is shown. pnpm 12+ (download_pnpm_native_package_manager) is the same. Links point to fc8cf35.
- The install directory is keyed by the pin and the platform origin, under
.verified-v1(L2016). - A complete install in that directory is reused with no check (L2023).
- The pin is checked against the main tarball.
fetch_registry_integrityreturnsNonewhendist.integrityis absent (L2193-L2199).- The platform tarball is downloaded and extracted with no expected digest (L2074).
publish_installmoves it into the directory from step 1 (L2132).
The namespace documentation says "Only a download verified against its pin creates a directory here, so a reuse check can trust a complete entry without re-reading the pin" (L211-L216). This path does not follow that rule.
Reproduction
A mock registry serves these responses for each manager:
- the main tarball, with a matching
packageManagerhash - the platform tarball
- the platform version document
{"dist": {}}
download_package_manager(kind, version, Some(pin)) then gives these results:
| pnpm 12.0.0-beta.0 | Bun 1.2.0 | |
|---|---|---|
| First install | Ok, in .verified-v1/<version>/<key>/ |
Ok, in .verified-v1/<version>/<key>/ |
| Installed executable | The unchecked platform file | The unchecked platform file |
Second run, after the registry serves a dist.integrity that does not match |
Ok, 0 metadata requests |
Ok, 0 metadata requests |
No message appears at the default log level.
Impact
Low, in my assessment. The registry serves both the tarball and dist.integrity, so this check cannot stop a malicious registry. The check detects inconsistency, such as a mirror sync error or a wrong file from a CDN. Without the field, vp cannot detect such a file, and the pinned install keeps it until the user removes it.
registry.npmjs.org serves dist.integrity for these platform packages, so this path needs a third-party mirror or a private registry. I did not check which registry products omit the field.
History
- feat(pm): verify bun platform tarball against dist.integrity #2310 added the platform check. It returns
Nonewhen the field is absent. - fix(pm): verify and content-key managed package-manager installs #3400 added
.verified-v1and put pinned Bun and pnpm 12+ installs in it. - fix(pm): verify unpinned package-manager downloads against registry integrity #3547 applied the same fallback to unpinned installs, "so a mirror without dist.integrity keeps working".
On main, a 404 for the platform version document fails, but an absent field continues. Both cases mean that the registry cannot supply an integrity. #3553 (draft) keeps the 404 failure for pinned Bun and pnpm 12+ installs, and lets unpinned installs continue.
Options
- Fail for pinned native installs. When the field is absent, a pinned Bun or pnpm 12+ install fails with a dedicated error. Unpinned installs continue. This matches the 404 rule in fix(pm): require registry integrity for package-manager downloads that no pin covers #3553 and keeps the
.verified-v1rule true. A pinned project on a mirror withoutdist.integritystops working. - Continue with a warning. Show a warning that users can see, and correct the
.verified-v1documentation. vp still reuses the unchecked file. - No behavior change. Correct the documentation only.
I recommend option 1. A project that declares a hash asks for a strict check. The open question is how many mirrors omit dist.integrity.
A separate, later step could check dist.signatures against the npm registry keys. That check authenticates the integrity itself, but it needs embedded keys and a key rotation policy.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Effort
Target date
Start date
Activity
voidzero-bot commentedon Nov 23, 2026
main, with a mock registry serving{"dist": {}}for the platform package, a pinnedpnpm 12.0.0-beta.0andBun 1.2.0install both succeeded into.verified-v1with the unchecked platform executable, and a second run reused it with 0 metadata requests.crates/vp_pm_cli/src/package_manager.rs(pinned_native_install_requires_platform_integrity, covering both pnpm 12 and Bun).verified-v1invariant, but only on the narrow configuration described here (a hash-pinned Bun/pnpm ≥ 12 install against a mirror or private registry that omitsdist.integrity), and the issue itself rates the impact low: the check detects registry/CDN inconsistency rather than stopping a malicious registry. A workaround exists (use a registry that serves the field, or drop thepackageManagerhash), though dropping the pin forfeits the strict check the pin asks for.For Bun and pnpm ≥ 12, the
packageManagerhash covers only the main tarball, and the executed binary comes from a platform package (@oven/bun-*/@pnpm/exe.*).fetch_registry_integrityincrates/vp_pm_cli/src/package_manager.rsreturnsOk(None)when the version document omitsdist.integrity, sodownload_bun_package_manager/download_pnpm_native_package_managerdownload and extract the platform tarball with no digest check, thenpublish_installwrites it into the keyed.verified-v1directory — breaking that namespace's documented rule that only a verified download creates an entry there. The completeness fast path then reuses the unchecked executable on every later run with zero registry requests, even if the registry later serves an integrity that would not match.I found a potential fix for this issue. Following the issue's option 1 (and the direction of draft PR #3553 for the 404 case), the fix in the triagebot/fix-3554 branch fails a pinned Bun or pnpm ≥ 12 install with a new, actionable
PackageManagerIntegrityUnavailableerror before the platform tarball is downloaded, while unpinned installs keep the #3547 fallback so mirrors withoutdist.integritykeep working. The regression test fails without the guard and passes with it; this still needs human review, in particular the trade-off that a pinned project on an integrity-less mirror stops working.Full Triage Report
Triage report — gh-3554
Step: reproduce
Result: REPRODUCED on current
main(Bug)Classification: Bug — a pinned Bun / pnpm ≥ 12 install caches an unchecked executable in the
.verified-v1namespace when the registry's platform version document omitsdist.integrity.Summary
download_bun_package_manager/download_pnpm_native_package_manager(crates/vp_pm_cli/src/package_manager.rs) verify the platform tarball only against the registrydist.integrityof the platform package.fetch_registry_integrityreturnsNonewhen the field is absent (package_manager.rs,RegistryVersionMetadata/RegistryDistuse#[serde(default)],dist.integrity: Option<Str>).Noneis forwarded as the expected digest todownload_and_extract_tgz_with_hash_and_config, so the platform tarball is downloaded and extracted with no check.publish_installthen moves it into the keyed.verified-v1directory thatinstall_cache_keyderived from the pin and the registry origin — although nothing was verified.is_package_manager_install_completereuses that directory with no check and no metadata request.VERIFIED_NAMESPACE: "Only a download verified against its pin creates a directory here, so a reuse check can trust a complete entry without re-reading the pin."Versions
mainat the workflow HEAD (branchtriagebot/fix-3554);vp v1.7.0from the installed local buildcrates/vp_pm_cli(cargo test -p vp_pm_cli --lib)Reproduction
The issue's reproduction is a Rust API-level one (
download_package_manager(kind, version, Some(pin))against a mock registry), so I reproduced it with a temporary unit test incrates/vp_pm_cli/src/package_manager.rsusing the crate's existing httpmock-based test helpers (create_tgz,sri,EnvConfig::with_vars_async). Test logic (bothpnpm 12.0.0-beta.0andbun 1.2.0):{"dist": {}}(no integrity).download_package_manager(kind, version, Some(pin))with a pin that matches the main tarball..verified-v1, is complete, and its native executable is the unchecked platform file.dist.integritythat does not match the platform tarball, then calldownload_package_manageragain with the same pin.Command
cargo test -p vp_pm_cli --lib repro_3554 -- --nocaptureOutput (exit code 0)
The test passing means the reported behavior held exactly as the issue describes:
dist.integrity)Ok, directory under.verified-v1/<version>/<key>/Ok, directory under.verified-v1/<version>/<key>/dist.integrityOk, 0 metadata requests (cache reused, no check)Ok, 0 metadata requests (cache reused, no check)No error or warning is emitted at the default log level.
Control
The existing test
test_download_bun_package_manager_verifies_hashes(unmodified, currentmain) shows the intended behavior when the registry does serve a mismatching integrity for the platform package: the pinned install fails withError::HashMismatch(1 metadata hit, tarball downloaded, nothing installed). This rules out an unrelated failure in the harness: the only difference between the control and the reproduction is the absence of thedist.integrityfield, and absence is exactly what lets the unchecked executable through.Code path confirmed (current
main)fetch_registry_integrityreturnsOk(None)whendistis{}— no error, no fallback.download_and_extract_tgz_with_hash_and_config(..., platform_hash.as_deref(), ...)receivesNone→ no digest check.install_cache_key(Some(pin), Some(origin))still derives a key, sopublish_installwrites the unchecked install into.verified-v1.is_package_manager_install_completefast path reuses it on later runs with zero registry requests.Diagnosis — gh-3554
Confidence: high — the failing logic and its effect are proven by code inspection and by the reproduction in the previous step.
Affected layer
crates/vp_pm_cli/src/package_manager.rs(package-manager install/download) andcrates/vp_pm_cli/src/request.rs(download-verify-extract pipeline). No JS, global-CLI, or upstream-involvement component.Root cause
For platform-binary managers (Bun, pnpm ≥ 12), the executed file comes from a platform package (
@oven/bun-{os}-{arch}/@pnpm/exe.{os}-{arch}) that thepackageManagerpin does not cover, so the only integrity check on that file is the registry'sdist.integrity. Three pieces of code combine into the bug:fetch_registry_integrity(~L2172–L2203): parses the platform version document with#[serde(default)], so{"dist": {}}deserializes successfully and the function returnsOk(None). Only a 404 is mapped toPackageManagerVersionNotFound; a document without the field is not an error. This tolerant "None means no check" contract dates from feat(pm): verify bun platform tarball against dist.integrity #2310 (e642d04).The native download functions (
download_bun_package_manager~L1998,download_pnpm_native_package_manager~L2205): they computeinstall_cache_key(Some(pin), Some(platform_origin))before verification and passplatform_hash.as_deref()(i.e.None) intodownload_and_extract_tgz_with_hash_and_configfor the platform tarball. Inrequest.rs,download_and_extract_tgz_once(~L549) runsverify_file_hashonlyif let Some(tarball_hash), so withNonethe tarball is downloaded and extracted with no digest check.publish_installthen moves the unchecked content into the.verified-v1/<version>/<key>/directory. The pin was verified only against the main tarball, which holds placeholders, not the executed binary — e.g.bun-1.2.0.tgzhas a 0-bytepackage/bin/bun.exe, andpnpm-12.21.0.tgzships a shell-script stub.The reuse fast path (
is_package_manager_install_completeat the top of both functions, ~L2023/L2226): a complete directory in the keyed namespace is returned immediately with zero registry requests. This trust is licensed by the invariant documented atVERIFIED_NAMESPACE(~L215): "Only a download verified against its pin creates a directory here, so a reuse check can trust a complete entry without re-reading the pin." Step 2 breaks that invariant: a complete.verified-v1entry can now hold never-verified content, and it is reused forever — even if the registry later serves a mismatchingdist.integrity, no recheck ever happens because no metadata request is made.Why the generic (non-platform) manager path does not have this bug
In the tarball-manager branch (
download_package_manager_inner~L1844), a pin covers the executed files themselves, soregistry_integrityis only fetched unpinned; there,Ok(None)is the deliberate #3547 fallback ("a mirror without dist.integrity keeps working") and the install goes to the unkeyed version directory, not.verified-v1. The bug is specific to the platform-binary managers with a pin, where the fallback semantics offetch_registry_integrityare reused even though the caller intends a verified, keyed install.Regression evidence (history)
Option/absent-tolerant contract..verified-v1and key-addressed pinned installs — creating the invariant that this path violates, without adding an absent-field case.dist.integrity:test_download_bun_package_manager_verifies_hashesandtest_download_package_manager_pnpm_v12_nativealways mount an integrity (mount_platform_registryalways passesSome), and the second-run assertions there check reuse of verified installs. The gap is exactly{"dist": {}}+Some(pin)— the case in the reproduction.Suggested fix approach (issue option 1 — fail pinned native installs)
In
download_bun_package_manageranddownload_pnpm_native_package_manager, treat an absent platformdist.integrityas an error only whenexpected_hashisSome, before any download/extract happens:PackageManagerIntegrityUnavailable { name, version, url }) rather than reusing a hash-mismatch error, since nothing was compared..verified-v1invariant literally true, which is what makes the lock-free, no-recheck reuse safe.Edge cases: a pinned project on a third-party mirror or private registry that omits
dist.integritystops working; the error message says what to do (serve the integrity, or drop the pin). The issue accepts this trade-off; npmjs itself serves the field. A 404 on the platform version document already fails (PackageManagerVersionNotFound) for both pinned and unpinned; after the fix the two "registry cannot supply an integrity" cases behave consistently for pinned installs, matching #3553's draft direction. Thedist.signaturesidea in the issue is out of scope for this fix.Verification — gh-3554
Verdict:
bug— the behavior contradicts documented design intent in the code and in the pull requests that built this layout.Confidence: high — direct written evidence from the code comments, the commit that introduced the namespace, and a maintainer-authored open PR.
Evidence of intent (this is not a chosen behavior)
VERIFIED_NAMESPACEincrates/vp_pm_cli/src/package_manager.rs(L215–216, PR fix(pm): verify and content-key managed package-manager installs #3400): "Only a download verified against its pin creates a directory here, so a reuse check can trust a complete entry without re-reading the pin." The reproduced path violates both halves: the directory is created by an unverified download, and the completeness fast path then trusts it without any check.dist.integrity". The absent-field case is not acknowledged anywhere in the PR.Optioncontract predates the namespace.fetch_registry_integrityreturningNonewhen the field is absent was introduced by feat(pm): verify bun platform tarball against dist.integrity #2310, before.verified-v1existed. fix(pm): verify and content-key managed package-manager installs #3400 reused the helper without handlingNonefor pinned installs — a gap, not a decision. No comment, doc, or test in the repository asserts that a pinned native install may proceed without an integrity.dist.integrity") is explicitly restricted to installs with no pin.dist.integrity; no test pins and omits the field.Counter-considerations (weighed)
.verified-v1invariant is a load-bearing correctness rule for the lock-free reuse fast path, and this path breaks it.Fix — gh-3554
Result: fixed. Implemented the issue's option 1, matching the direction maintainers already chose in draft PR #3553: a pinned Bun or pnpm ≥ 12 install fails with a dedicated error when the platform version document omits
dist.integrity; unpinned installs keep the tolerant fallback.Changed files
crates/vp_error/src/lib.rs— new error variantPackageManagerIntegrityUnavailable { name, version, url }with an actionable two-line message (use a registry that servesdist.integrity, or remove thepackageManagerhash).nameis the platform package (@oven/bun-*/@pnpm/exe.*),urlthe platform version document.crates/vp_pm_cli/src/package_manager.rs— indownload_bun_package_manageranddownload_pnpm_native_package_manager, afterfetch_registry_integrity, a pinned install that receivedNonenow returnsPackageManagerIntegrityUnavailablebefore the platform tarball is downloaded. Documented theOk(None)contract onfetch_registry_integrity. The.verified-v1invariant is restored: no unverified content can enter the keyed namespace, so the no-recheck reuse fast path stays sound.crates/vp_pm_cli/src/package_manager.rs(tests) — regression testpinned_native_install_requires_platform_integritynext totest_download_bun_package_manager_verifies_hashes, covering both pnpm 12.0.0-beta.0 and Bun 1.2.0: pinned +{"dist": {}}→ the new error (fields asserted, nothing installed, platform tarball never requested); unpinned +{"dist": {}}→ still installs via the fallback, outsideVERIFIED_NAMESPACE.Alternatives considered (from the issue)
Regression test evidence
cargo test -p vp_pm_cli --lib pinned_native_install_requires_platform_integrity→ 1 passed.a pinned pnpm install without 'dist.integrity' must fail.Err(PackageManagerIntegrityUnavailable)for the pinned cases; the unpinned control (and all existing integrity-serving tests) behave unchanged.Validation
cargo test -p vp_pm_cli(lib 989 +package_manager_pin_verificationintegration)RUST_MIN_STACK=8388608 cargo test -p <all workspace crates> -p vite-plus-cli(just test, minus trampoline)cargo check --workspace --all-features --all-targets --locked(just check)nix v0.28.0future-incompat warning only)cargo clippy --workspace --all-targets --all-features -- --deny warnings …(just lintmain part)cargo fmt --all --checkgit diff --checkSkipped checks (with reasons)
cargo test --manifest-path crates/vp_trampoline/Cargo.toml(part ofjust test): the trampoline is outside the workspace and untouched by this change.just snapshot-test/just snapshot-test-global: no snapshot fixture exercises a hash-pinned native manager against an integrity-less registry (fixture pins are hashless for pnpm 12, e.g.[email protected], and hashed pins are pnpm 10, a tarball manager), and the global-flavor runner executes the pre-installedvpbinary, which predates this change.pnpm bootstrap-cliend-to-end: the JS CLI is untouched.Follow-up notes (not in this fix)
.verified-v1by a pre-fix binary is still trusted by the completeness fast path; clearing it would need a layout migration (a.verified-v2bump) and is a separate decision.is_integrity_failurewas left unchanged: the new error says a check was impossible, not that an artifact failed a check, and it currently has no non-test callers.dist.signaturesverification (issue's last paragraph) remains future work.This report was made by an LLM. The analysis may be wrong, and the potential fix might not work, but is intended as a starting point for exploring the issue.
I've opened a pull request with this fix: #3555
docs(pm): limit the pinned native install comment to the 404 case
docs(pm): limit the pinned native install comment to the 404 case
docs(pm): limit the pinned native install comment to the 404 case
fix(pm): require registry integrity for package-manager downloads tha…