Hosted scan on a pnpm workspace with `sharedWorkspaceLockfile: false` ignores the per-package pnpm-lock.yaml files and reports success while redirecting nothing
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 68/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- rust
- Lĩnh vực
- build-system, cli, devtools
Hướng nghiên cứu
Start in crates/socket-patch-core/src/hosted/engine.rs at read_candidate_files and inspect crates/socket-patch-core/src/formats/pnpm/hosted.rs around redirect_pnpm_entry_not_found. Run the e2e_redirect_pnpm_build.rs harness against the sharedWorkspaceLockfile=false reproduction. Done means member pnpm-lock.yaml files are handled with the root workspace trust edit, or the scan fails closed instead of reporting success with no redirects.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
[agent] Found by the scheduled pnpm bug-hunt routine (ledger #303).
Summary
With sharedWorkspaceLockfile: false (shared-workspace-lockfile=false in .npmrc on older majors), pnpm writes one pnpm-lock.yaml per workspace package (packages/a/pnpm-lock.yaml, packages/b/pnpm-lock.yaml, …). The root pnpm-lock.yaml covers only the root importer, and is often just importers: .: {}.
scan --mode hosted from the workspace root finds the vulnerable package in node_modules, then reads only the root lock (plus the Rush locks when rush.json exists). The member locks that pnpm actually installs from are never opened. The run ends with exit 0, status: success, redirect.redirected: 0, rewrittenFiles: [], and one redirect_pnpm_entry_not_found warning ("no resolution for [email protected]"). Every package in the workspace keeps installing the unpatched registry tarball.
Impact
- Hosted mode silently does nothing on this documented pnpm layout.
success/ exit 0 tells CI and users the project is patched when no lock was changed. - VEX stays honest: with nothing pinned,
vexfinds nothing to attest. So the failure is "unpatched, but reported as a successful hosted scan", not a false attestation. - The obvious workaround fails on pnpm 11+. Running
scan --mode hosted --cwd packages/adoes pinpackages/a/pnpm-lock.yaml, but it also createspackages/a/pnpm-workspace.yaml(packages: ['.']+trustLockfile: true). That turns the member into a nested workspace root, and pnpm ignores the file when installing from the real root. A freshpnpm install --frozen-lockfilefrom the root on pnpm 12.8.1 then fails withERR_PNPM_TARBALL_URL_MISMATCH. - Vendored mode on the same layout refuses loudly (
vendor_lock_entry_not_found, partialFailure, exit 1), which is acceptable fail-closed behaviour.
Repro
mkdir -p ws/packages/a ws/packages/b && cd ws
echo '{"name":"root","version":"0.0.0","private":true}' > package.json
echo '{"name":"a","version":"1.0.0","dependencies":{"is-number":"7.0.0"}}' > packages/a/package.json
echo '{"name":"b","version":"1.0.0","dependencies":{"to-regex-range":"5.0.1"}}' > packages/b/package.json # [email protected] transitively
printf "packages:\n - 'packages/*'\nsharedWorkspaceLockfile: false\n" > pnpm-workspace.yaml
echo 'shared-workspace-lockfile=false' > .npmrc # pnpm <= 10 reads this
pnpm install
ls pnpm-lock.yaml packages/*/pnpm-lock.yaml # three locks; the root one is `importers: .: {}`
socket-patch scan --mode hosted --json --yes ... # patch for pkg:npm/[email protected] is available
# status: success, exit 0, redirect.redirected: 0, rewrittenFiles: [],
# warnings: [{code: redirect_pnpm_entry_not_found, detail: "no resolution for [email protected]"}]
grep -c 'tarball:' packages/*/pnpm-lock.yaml # 0 everywhere
# fresh checkout + pnpm install --frozen-lockfile -> both a and b load the upstream bytes
(I ran this against a local mock of the patch API: batch / by-package / package grant / view / hosted tarball, with SOCKET_PATCH_SERVER_URL and SOCKET_NPM_REGISTRY pointed at it, the same harness as the repo's e2e_redirect_pnpm_build.rs. The oracle is a marker prepended to is-number/index.js.)
Expected vs actual
- Expected: docs/ecosystems.md (npm hosted-mode notes) says pnpm "workspaces … are handled. Every matching package instance is rewritten; an unsupported instance prevents confirming that dependency across the lockfile set." A pnpm workspace's lockfile set includes its per-package locks when
sharedWorkspaceLockfileis false, so eachpackages/*/pnpm-lock.yamlthat resolves the package should be pinned, withtrustLockfilegoing into the rootpnpm-workspace.yaml. At minimum, the run should fail closed (partialFailure / non-zero, as vendored does) instead of reportingsuccess. - Actual: only the root lock is read, nothing is rewritten, and the status is
success, exit 0.
Matrix (Linux, main 61cfb9b)
| OS | pnpm | lock | hosted from the workspace root | vendored from the root |
|---|---|---|---|---|
| Linux | 8.15.9 | 6.0 | fail (success, 0 redirected) | not run |
| Linux | 9.15.9 | 9.0 | fail (2/2) | refuses vendor_lock_entry_not_found (OK) |
| Linux | 10.34.5 | 9.0 | fail | refuses (OK) |
| Linux | 11.28.3 | 9.0 | fail | refuses (OK) |
| Linux | 12.8.1 | 9.0 | fail (2/2) | refuses (OK) |
| Linux | 12.8.1 | 9.0 | workaround --cwd packages/a: lock pinned, but the root frozen install fails with ERR_PNPM_TARBALL_URL_MISMATCH |
Control: the same workspace with the default shared lock is redirected, installs patched bytes in both members, and rolls back byte for byte (passes on 9.15.9 / 10.34.5 / 11.28.3 / 12.8.1). macOS and Windows weren't probed, but the code path is OS-independent.
Not bisected. The 4.0.0 release can't be driven against the v5-shaped mock, and the candidate-file list has never included member locks.
Suspect code
crates/socket-patch-core/src/hosted/engine.rs:404(read_candidate_files): it readsREDIRECT_CANDIDATE_FILES(rootpnpm-lock.yaml), Cargo members, Python locks and the Rush locks (:449,rush_repo), but it never expands thepnpm-workspace.yamlpackages:globs into per-memberpnpm-lock.yamlkeys. The comment there notes that the pnpm rewriter is already basename-generalized for nested keys, so adding member locks (and pointing the trust edit at the root workspace file) looks like the shape of a fix.crates/socket-patch-core/src/formats/pnpm/hosted.rs:393:redirect_pnpm_entry_not_foundis a warning only, so the miss doesn't affect the status.
- Ngôn ngữ chính
- Rust
- Star
- 8
- Fork
- 0
- Merge trung bình
- 1 ngày 7 phút
- Pull request đã merge (30 ngày)
- 178
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của SocketDev/socket-patch
-
Hosted yarn classic pins give no berry-migration warning, so a yarn 2+ install silently drops them (vendored warns about the same trap)Có thể đã có người làm @mikolalysenko đã nhận hôm nay. Đang mởagent:claimed agent:triaged bug bughunt pm:yarn-classic priority:p1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
SocketDev/socket-patch#907 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged bug bughunt pm:npm priority:p1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
SocketDev/socket-patch#900 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged bug bughunt pm:bundler priority:p1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
SocketDev/socket-patch#896 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged bug bughunt pm:yarn-berry priority:p1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
SocketDev/socket-patch#783 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged bug bughunt pm:pipenv priority:p1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
SocketDev/socket-patch#744 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của SocketDev/socket-patch
Issue tương tự
-
Signals (Failure Detector): a tool call and its own execution are reported as a repeated callĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
check: a failed re-read of the model file before binding is labelled E_THETA_LEVEL_BINDING on [parameters]Có thể đã có người làm @TeunP đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
Devolutions/picky-rs#546 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày