Skip to content

fix(pm): verify unpinned package-manager downloads against registry integrity - #3547

Merged
fengmk2 merged 7 commits into
voidzero-dev:mainfrom
jong-kyung:fix/verify-unpinned-pm-integrity
Nov 23, 2026
Merged

fengmk2 merged 7 commits into
voidzero-dev:mainfrom
jong-kyung:fix/verify-unpinned-pm-integrity

Conversation

@jong-kyung

@jong-kyung jong-kyung commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Without a packageManager hash, Vite+ installed npm, pnpm 11 and earlier, and Yarn without any integrity check. Bun and pnpm 12 and later already verified their platform tarball against the registry dist.integrity, so the same unpinned project was verified or not depending on the package manager. Corepack used to verify these downloads, and that check was lost when it was removed in #2391.

An unpinned download now fetches the version metadata and verifies the tarball against dist.integrity before extraction. A pinned download is unchanged. It is still verified against the pin and does not fetch metadata, which keeps the principle from #3400 that a declared pin takes precedence over what the registry reports.

…ntegrity

Without a `packageManager` hash, npm, pnpm 11 and earlier, and Yarn were
installed without any integrity check, while bun and pnpm 12+ already
verified their platform tarball against the registry `dist.integrity`.
Corepack used to verify these downloads before it was removed.

An unpinned download now fetches the version metadata and verifies the
tarball against `dist.integrity` before extraction. A pinned download keeps
using the pin and does not fetch metadata. A registry that omits
`dist.integrity` now fails the install with `MissingRegistryIntegrity`
for every manager, including the bun and pnpm 12+ platform tarballs.
@jong-kyung jong-kyung self-assigned this Nov 23, 2026
@jong-kyung jong-kyung added test: e2e Auto run e2e tests test: install-e2e run vite install e2e test test: create-e2e Run `vp create` e2e tests test: sfw labels Nov 23, 2026
@jong-kyung

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T05:21:43.678511Z bfba722 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Match the existing bun and pnpm 12+ platform tarball behavior instead of
failing the install, so a mirror without dist.integrity keeps working.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: edf37a510e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/vp_pm_cli/src/package_manager.rs Resolved
The test served only the tarball, so the new metadata request returned 404
before the temp dir existed and the cleanup assertion passed vacuously.
Use is_not_found for registry 404 mapping, name managers by
PackageManagerType, and share the test sri and mount helpers. Remove doc
and inline comments that restate the code.
@jong-kyung

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 75fc3cc5d8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jong-kyung
jong-kyung marked this pull request as ready for review November 23, 2026 05:15
An unpinned npm download now reads dist.integrity from the version
metadata, so the mock registry must answer that request.
@jong-kyung
jong-kyung marked this pull request as draft November 23, 2026 05:17
@jong-kyung
jong-kyung marked this pull request as ready for review November 23, 2026 05:18
@fengmk2
fengmk2 merged commit fc8cf35 into voidzero-dev:main Nov 23, 2026
147 of 149 checks passed
@jong-kyung
jong-kyung deleted the fix/verify-unpinned-pm-integrity branch November 23, 2026 06:28
fengmk2 added a commit that referenced this pull request Nov 23, 2026
…t no pin covers (#3553)

## Summary

#3547 checks unpinned package-manager downloads against the registry
`dist.integrity`. When the version document omitted the field, the
install continued without a check. When the version document returned
404, the install failed with `PackageManagerVersionNotFound`, even if
the package document had the integrity.

This PR makes one rule: when no `packageManager` pin covers the files
that vp runs, vp requires the registry `dist.integrity`. The rule
applies to these downloads:

- Unpinned installs of every package manager.
- The platform package of Bun and pnpm 12+, with or without a pin. A pin
for these two managers covers only the main tarball, which holds no
executable.

Pinned npm, pnpm 11 and earlier, and Yarn installs do not change. They
never fetch metadata.

### Lookup

1. vp reads the version document, `<registry>/<name>/<version>`.
2. If that document returns 404 or omits `dist.integrity`, vp reads the
abbreviated package document, `<registry>/<name>`. `npm install` reads
the same document when no lockfile pins a package.
3. If neither document gives the integrity, the install fails with
`PackageManagerIntegrityUnavailable` before the download.

| Registry response | Before | After |
| --- | --- | --- |
| Version document has `dist.integrity` | Verified | Verified |
| Version document omits `dist.integrity` | Installed without a check |
Verified with the package document |
| Version document 404 | `PackageManagerVersionNotFound` | Verified with
the package document |
| Neither document gives `dist.integrity` | Installed without a check,
or `PackageManagerVersionNotFound` on a 404 |
`PackageManagerIntegrityUnavailable`, nothing downloaded |
| Package document does not list the version | Not read |
`PackageManagerVersionNotFound` |

On registry.npmjs.org, every version of `npm`, `pnpm`, `yarn`,
`@yarnpkg/cli-dist`, and `bun` has `dist.integrity`, and so does every
version of the Bun and pnpm platform packages that I sampled. So the
first request succeeds there.

### The new error

`PackageManagerIntegrityUnavailable` names the package and the package
document URL, and gives a hint:

- npm, pnpm 11 and earlier, and Yarn: add an integrity hash to the
`packageManager` field, or use a registry that serves package metadata.
- Bun and pnpm 12+: use a registry that serves package metadata. A pin
does not help, because it does not cover the platform package.

`Error::is_integrity_failure` includes the new error. So a command that
prepares a managed package manager stops with this error, and does not
fall back to the package manager on `PATH`.

Closes #3554

### One descriptor for each download

`download_and_extract_tgz_with_hash_and_config` took `archive_file`,
`expected_hash`, and `tarball_hash`. `expected_hash` covered the archive
or one entry, depending on `archive_file`. Without `archive_file`, the
two hash parameters were the same check.

`download_and_extract_tgz` now takes a `TgzDownload`:

- `archive_digest` always covers the `.tgz` bytes, and vp checks it
before it reads any entry.
- `unpack` is `Unpack::All`, or `Unpack::Entry { path, digest }`, where
`digest` covers the extracted file only.

`download_package_manager_inner` selects both values in one place. Bun
and pnpm 12+ share `verify_pin_and_fetch_platform_integrity`, which
checks the pin against the main tarball and then fetches the platform
integrity.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@fengmk2 fengmk2 mentioned this pull request Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test: create-e2e Run `vp create` e2e tests test: e2e Auto run e2e tests test: install-e2e run vite install e2e test test: sfw

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants