Agent-mode npm `vex` hashes only the first installed copy of a package, so it attests not_affected while another nested copy of the same name@version is unpatched
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ó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/100
Hướng nghiên cứu
Read crates/socket-patch-cli/src/commands/vex.rs:556 and ecosystem_dispatch.rs:401, then review the verification table in crates/socket-patch-cli/CLI_CONTRACT.md:390. Run the supplied npm reproduction to observe the incorrect not_affected result. Done means agent-mode attestation accounts for every installed copy of the PURL and matches the documented not_applied or hash_mismatch behavior when any copy is unpatched.
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 npm bug-hunt routine (ledger #302).
Summary
In agent mode, vex checks only the first installed copy of each manifest PURL (crates/socket-patch-cli/src/commands/vex.rs:556, let package_paths = collapse_to_first(copies.clone());). Hosted-basis PURLs are checked against every copy (vex_consumed::hosted_consumed_copies), but agent records are not. When an npm tree holds several nested copies of the same name@version and only some of them are patched, the verdict depends on crawl order:
- first copy patched, another copy unpatched →
not_affected(wrong); - first copy unpatched, another copy patched →
not_applied(right, by luck).
The Deno routine found this (handover on #302). I confirmed it with plain npm, where the trigger is common: apply patches every copy present, and a later npm install of a new dependent extracts a fresh, unpatched nested copy while leaving the patched one alone.
Impact
The VEX document says not_affected while an unpatched copy of the vulnerable code is still in node_modules and gets loaded by its dependent (is-accessor-descriptor here). apply is fine: re-running it patches the new copy. Only the attestation is wrong.
Repro (real npm, Linux, main 61cfb9b)
SP=/path/to/target/release/socket-patch
mkdir npmdup && cd npmdup && echo '{"name":"npmdup","version":"1.0.0"}' > package.json
npm install [email protected] [email protected] # nests [email protected] under is-number
# Hand-stage .socket/manifest.json + .socket/blobs with a patch for pkg:npm/[email protected]
# that changes package/index.js (beforeHash = pristine, afterHash = pristine + a comment line),
# with one vulnerability carrying a CVE. Any free patch works too.
$SP apply --offline # 1 of 1 targeted patch applied
npm install [email protected] # adds is-accessor-descriptor/node_modules/[email protected], unpatched
$SP vex --offline -O v.json; echo $? # exit 0, 1 statement: not_affected
State after the second install:
node_modules/is-number/node_modules/kind-of 3.2.2 patched
node_modules/is-accessor-descriptor/node_modules/kind-of 3.2.2 UNPATCHED
node_modules/kind-of 6.0.3 (not targeted)
vex output: Wrote OpenVEX document with 1 statement to v.json, status not_affected.
Crawl-order check on the same tree: restore the is-number copy to pristine and patch the is-accessor-descriptor copy instead, and vex omits the PURL (not_applied) and exits with "No applied patches with vulnerability metadata to attest."
Expected vs actual
- Expected: CLI_CONTRACT.md's verification table (
crates/socket-patch-cli/CLI_CONTRACT.md:390) says an agent record is verified against "the installed tree". An attestation should hold only when every installed copy the crawler finds for that PURL hashes to the patched bytes, as the hosted path already requires. Otherwise the PURL should be omitted (not_applied/hash_mismatch). - Actual: only the first copy is hashed, and
not_affectedis emitted with exit 0.
Matrix
| OS | npm | Node | main 61cfb9b |
v4.0.0 (with setup.manual: ["npm"]) |
|---|---|---|---|---|
| Linux | 8.19.4 | 22.22 | reproduces | not run |
| Linux | 10.9.4 | 22.22 | reproduces (2/2) | reproduces |
| Linux | 12.2.0 | 22.22 | reproduces | not run |
| macOS / Windows | — | — | not probed (the logic isn't OS-specific) | — |
First bad version
This isn't a v5 regression: v4.0.0 emits the same single not_affected statement once setup.manual is set. I didn't bisect further.
Suspect code
crates/socket-patch-cli/src/commands/vex.rs:556:collapse_to_first(copies.clone())feedsapplied_patches_with_vendor, which hashes one path per PURL for agent records.crates/socket-patch-cli/src/ecosystem_dispatch.rs:401:collapse_to_first.
The same pattern probably hits every npm-family layout that can hold several copies of one version (yarn classic and bun hoisted, Deno's hoisted linker, pnpm peer variants), but this issue covers npm only.
Related but different: #325 (bundled copies, hosted in-run --vex), #435 (pnpm global), #405 (bun isolated).
- Ngôn ngữ chính
- Rust
- Star
- 8
- Fork
- 1
- Merge trung bình
- 18 giờ 19 phút
- Pull request đã merge (30 ngày)
- 504
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
-
agent:triaged bug bughunt pm:npm priority:p3 ux
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
SocketDev/socket-patch#1072 · 2 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
-
Vendored cargo warns cargo_multi_version_old_cargo ("declares no rust-version") when the root package inherits rust-version from [workspace.package]Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởagent:triaged bug bughunt pm:cargo priority:p2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
SocketDev/socket-patch#651 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug bughunt pm:npm
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
SocketDev/socket-patch#1481 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Hosted gem scan ignores a Gemfile `lockfile "custom.lock"` DSL call (Bundler 4), so it pins the unused Gemfile.lock, leaves the real lock untouched, and every frozen install failsCó thể đã có người làm @mikolalysenko đã nhận hôm nay. Đang mởagent:claimed agent:triaged bug bughunt pm:bundler priority:p1
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
SocketDev/socket-patch#1477 · 3 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ự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
cmlarsen/writemorebetter#158 ·
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 72/100
-
state:triage-needed
Độ 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ó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
scanaislop/aislop#482 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
docs(skills): issue-first should reference an existing Linear ticket instead of filing a duplicateĐang mởdocumentation
Độ khó 1/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