Since #446, `scan -g --mode agent` then `rollback -g` from a vendored NuGet project reverts the project's patched package in the shared global packages folder; the locked restore stays "up-to-date" and VEX keeps attesting
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
- 58/100
Hướng nghiên cứu
Start with the NuGet reproduction in crates/socket-patch-cli/tests/e2e_nuget_dotnet_build.rs, then trace vendor_owned_purls in commands/scan/mod.rs:1652-1658 and commands/apply.rs:1720. Read commands/rollback.rs:1121 and commands/mod.rs:44 to compare global and project scope handling. Done means global scan/apply/rollback cannot silently unpatch a vendored NuGet install, and VEX no longer attests bytes that are not patched.
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 NuGet / dotnet bug-hunt routine (ledger #320).
Summary
#446 (551c362, "Keep -g runs off the project's hosted/vendored state") made global runs ignore the project's vendor ledger: scan -g --mode agent / apply -g now patch "the global copy of a purl the project vendors", and rollback -g rolls that copy back. That works for npm, where the global copy is separate from node_modules. For NuGet it isn't separate. A PackageReference project restores into the global packages folder (~/.nuget/packages, or NUGET_PACKAGES), so the "global copy" is the vendored project's own installed copy.
From a vendored NuGet project on main:
scan -g --mode agent --yesfinds[email protected]in the global packages folder. Those bytes are already patched, because the project's locked restore extracted them from the vendored nupkg. The scan reportsapplied: 1and writes an agent record to the project's.socket/manifest.json. Before #446 it was skipped asvendored_ownership_retained.rollback -g --yesthen restores the upstream bytes into~/.nuget/packages/newtonsoft.json/13.0.3/(rolledBack: 1, exit 0). It leaves the vendored wiring and ledger alone, which is what #446 intended.- The project's
dotnet restore --locked-modesays "All projects are up-to-date for restore". The lock still pins the vendored nupkg's contentHash, the.nupkg.sha512sidecar still matches, and NuGet never re-extracts. So the project builds unpatched, with exit 0 everywhere. vex --product pkg:nuget/[email protected]still emitsnot_affected"Patched via Socket patch … (vendored)". It warns that the live tree differs and says to "re-run your package manager's install to resync it", but the restore in step 3 is exactly that, and it doesn't resync.
Impact
A vendored NuGet project gets silently unpatched by a global agent run plus its rollback, both started from the repo root. That's a normal way to manage machine-wide patches, and with a project-level .socket/ present it's the documented place to run it. CI and dev boxes share one global packages folder. Nothing fails and VEX keeps attesting.
Repro (Linux, dotnet SDK 8.0.131, main 9d718cf)
I used a scratch copy of crates/socket-patch-cli/tests/e2e_nuget_dotnet_build.rs, keeping its wiremock Backend stand-in and the real nuget.org fixture restore:
fixture: app.csproj (net8.0, RestorePackagesWithLockFile, Newtonsoft.Json 13.0.3) + nuget.org-only nuget.config
socket-patch scan --mode vendored --vendor-source service --yes --api-url <backend> ... # exit 0, lock re-pinned, feed wired
NUGET_PACKAGES=<store> dotnet restore --locked-mode # store/newtonsoft.json/13.0.3/LICENSE.md = PATCHED
NUGET_PACKAGES=<store> socket-patch scan -g --mode agent --json --yes --api-url <backend> ...
# "applied": 1 (main) | "skipped": 1, vendored_ownership_retained (c7af4df, the parent of #446)
# main also writes .socket/manifest.json with an agent record for pkg:nuget/[email protected]
# (stage the before-blob in .socket/blobs, or run rollback online against a server that serves it)
NUGET_PACKAGES=<store> socket-patch rollback -g --json --yes --offline
# main: "rolledBack": 1, exit 0 -> store LICENSE.md = PRISTINE; vendored wiring + ledger untouched
NUGET_PACKAGES=<store> dotnet restore --locked-mode # exit 0, "All projects are up-to-date", store stays PRISTINE
socket-patch vex --offline --product pkg:nuget/[email protected] -o v.json
# 1 statement, not_affected, "Patched via Socket patch 4f4f… (vendored)" + resync warning
Reproduced 3 times on 9d718cf. The vex result was checked before the rollback (attested, bytes patched) and after it (still attested, bytes pristine).
Expected vs actual
- Expected: the #446 commit message and the README say a global run leaves "the project's state alone". For NuGet the global packages folder copy is the project's install of a vendored package. The pre-#446 skip (
vendored_ownership_retained) protected it, and so should-g, or at least the copy whose bytes match the vendored artifact. An agentapply -gthat finds bytes already atafterHashalso shouldn't reportappliedand take ownership of the record. CLI_CONTRACT.md / README VEX: VEX attests only patches that are actually applied to the product. - Actual:
-gtakes over and later reverts the project's installed copy. The restore can't notice, because only the extracted files changed, not the nupkg or its sha512. VEX keeps attesting.
OS × version
| OS | SDK | main 9d718cf |
c7af4df (before #446) |
|---|---|---|---|
| Linux | 8.0.131 | silently unpatched (3/3) | agent leg skipped (vendored_ownership_retained). rollback -g instead unwound the vendored wiring (#445), so the locked restore failed loudly with NU1403 |
The layout is the same on macOS and Windows (~/.nuget/packages, %USERPROFILE%\.nuget\packages), but I haven't run it there yet.
First bad commit
551c362 (#446). Before it, the same sequence was loud: #445's wiring unwind led to NU1403. Now it's silent.
Suspect code
crates/socket-patch-cli/src/commands/scan/mod.rs:1652-1658(vendor_owned_purlsis emptied under-g)crates/socket-patch-cli/src/commands/apply.rs:1720(same rule forapply -g)crates/socket-patch-cli/src/commands/rollback.rs:1121crates/socket-patch-cli/src/commands/mod.rs:44(project_state_in_scopetreats "global" and "project" installs as disjoint, which doesn't hold for NuGet's global packages folder)
Related, but a different trigger: #352 (a warm folder shadowing a vendored patch) and #450 (cross-scope rollback).
- Ngôn ngữ chính
- Rust
- Star
- 8
- Fork
- 0
- Merge trung bình
- 15 giờ 39 phút
- Pull request đã merge (30 ngày)
- 104
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: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 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:claimed agent:triaged arch-audit bug pm:hatch priority:p1
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 88/100
SocketDev/socket-patch#613 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:claimed agent:triaged arch-audit bug priority:p3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
SocketDev/socket-patch#571 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged bug bughunt pm:composer priority:p2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
SocketDev/socket-patch#515 · 1 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 82/100
SocketDev/socket-patch#464 · 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ự
-
area:release bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
registrystack/registry-stack#1874 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
component:midnight-toolkit status:untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
midnightntwrk/midnight-node#2237 ·
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 88/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 78/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 78/100
Maintainer thường phản hồi trong vòng 1 ngày