Project-mode NuGet agent scan patches, and VEX attests, packages the project doesn't depend on (the crawler lists the whole ~/.nuget/packages)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start in crates/socket-patch-core/src/crawlers/nuget_crawler.rs:74-78 and inspect how obj/project.assets.json libraries and packageFolders could determine project packages. Run the provided Linux reproduction and verify project-mode discovery no longer crawls unrelated global-cache packages, patches them, or includes them in VEX output.
由索引模型根据 Issue 内容生成。
描述
[agent] Found by the scheduled NuGet / dotnet bug-hunt routine (ledger #320).
Summary
Without -g, NuGet discovery for a .NET project lists every package in the user-wide global packages folder (~/.nuget/packages, %USERPROFILE%\.nuget\packages), not just the packages the project resolves. So, in a project that depends only on Newtonsoft.Json:
scanreports and looks up[email protected],netstandard.library, … left over from unrelated projects on the same machine.scan --mode agent --yesapplies a patch to[email protected]in the shared cache, which the project never uses, and records it in this project's.socket/manifest.json. Exit 0,1 of 1 targeted patch applied.vex --product pkg:nuget/[email protected]then emitsnot_affected/inline_mitigations_already_existwithpkg:nuget/[email protected]as a subcomponent ofApp. App doesn't contain serilog.
This is the NuGet twin of #265 (Maven: "the crawler lists all of ~/.m2").
Impact
- A false VEX: the product's attestation names components it doesn't ship. That pollutes SBOM/VEX consumers and can mask the real dependency set.
- Agent mode mutates bytes in a cache shared by every other project on the machine. The patch is recorded against this project, so another project's
rollback/repairdoesn't know about it. - Noise:
scanoutput and the patch-API batch carry the whole machine cache (hundreds of packages on a dev box or warm CI image).
Repro (Linux, dotnet SDK 8.0.131, main 2463257)
SP=/path/to/target/release/socket-patch
export SOCKET_NO_CONFIG=1 SOCKET_TELEMETRY_DISABLED=1
# another project on this machine uses Serilog
mkdir other && cd other && cat > O.csproj <<'X'
<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><TargetFramework>net8.0</TargetFramework></PropertyGroup><ItemGroup><PackageReference Include="Serilog" Version="3.1.1" /></ItemGroup></Project>
X
dotnet restore && cd ..
# our project depends only on Newtonsoft.Json
mkdir app && cd app && cat > App.csproj <<'X'
<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><TargetFramework>netstandard2.0</TargetFramework></PropertyGroup><ItemGroup><PackageReference Include="Newtonsoft.Json" Version="13.0.3" /></ItemGroup></Project>
X
dotnet restore
grep -ci serilog obj/project.assets.json # 0, not a dependency
# local stand-in for the public proxy (POST /patch/batch, GET /patch/by-package/<purl>,
# GET /patch/view/<uuid>) that serves one free patch for pkg:nuget/[email protected] (README.md + marker line)
$SP scan --mode agent --yes --proxy-url http://127.0.0.1:8766
# Found 4 packages (4 nuget) ... Patched packages: pkg:nuget/[email protected] (via blob)
# Summary: 1 of 1 targeted patch applied (exit 0)
grep -c SOCKET_MARKER ~/.nuget/packages/serilog/3.1.1/README.md # 1
$SP vex --offline --product pkg:nuget/[email protected]
# products[0] = pkg:nuget/[email protected], subcomponents = [pkg:nuget/[email protected]], status not_affected
Reproduced twice (rollback in between restores the bytes exactly). scan --json without --mode (report-only / hosted) also lists the unrelated packages.
Expected vs actual
- Expected: project-mode discovery covers the packages this project resolves. For PackageReference projects that's the
librariesinobj/project.assets.json(orpackages.lock.json); for packages.config, thepackages/folder. The VEX contract (README VEX section, CLI_CONTRACT.md) attests only what is patched in the product. The maintainers' global-mode note (ledger #320, 20261001T040000Z entry) also asks that a scan without-gnever touch the global location beyond the project. - Actual:
get_nuget_package_pathsadds the whole global packages folder as a crawl root in local mode, andcrawl_allemits every<id>/<ver>/in it.
OS × SDK matrix
| OS | SDK | unrelated cache package patched + attested |
|---|---|---|
| Linux (local) | 8.0.131 | yes (2/2 runs) |
The crawler code path is OS-independent (the same nuget_home() root is used on macOS and Windows; the probe run https://github.com/SocketDev/socket-patch/actions/runs/36820498426 shows the same ~/.nuget/packages / C:\Users\runneradmin\.nuget\packages root being crawled on all 3 OSes). I haven't separately run this agent-mode scenario on macOS or Windows.
First bad version
Not a regression: v4.0.0 (scan --apply --yes) patches [email protected] the same way.
Suspect code
crates/socket-patch-core/src/crawlers/nuget_crawler.rs:74-78 (// 2. Fall back to the global cache. pushes nuget_home() as a crawl root in local mode). A fix would crawl only the <id>/<ver> dirs named in obj/project.assets.json libraries (resolved against its packageFolders) instead of the whole folder. That would also fix the wrong-folder half of #397.
- 主要语言
- Rust
- 星标
- 8
- 派生
- 0
- 平均合并
- 18 小时 4 分钟
- 30 天内合并 PR
- 70
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
SocketDev/socket-patch 的其他 Issue
-
agent:triaged bug bughunt pm:composer priority:p2
难度 2/5 1-3 小时 新手友好度 90/100
SocketDev/socket-patch#515 · 1 条评论 ·
维护者通常 1 天内回复
-
agent:triaged bug bughunt pm:npm priority:p1
难度 2/5 1-3 小时 新手友好度 82/100
SocketDev/socket-patch#464 · 1 条评论 ·
维护者通常 1 天内回复
-
agent:triaged bug bughunt pm:npm priority:p1
难度 2/5 1-3 小时 新手友好度 82/100
SocketDev/socket-patch#433 · 1 条评论 ·
维护者通常 1 天内回复
-
agent:triaged bug bughunt pm:uv priority:p1
难度 2/5 1-3 小时 新手友好度 78/100
SocketDev/socket-patch#408 · 1 条评论 ·
维护者通常 1 天内回复
-
agent:triaged bug bughunt pm:yarn-berry priority:p1
难度 2/5 1-3 小时 新手友好度 82/100
SocketDev/socket-patch#370 · 2 条评论 ·
维护者通常 1 天内回复
查看 SocketDev/socket-patch 的全部 Issue
相似的 Issue
-
discover: `sudo RTK_DISABLED=$VAR …` is not detected as a bypass when `sudo` is a transparent prefix未关闭area:cli bug good first issue priority:medium
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
skill:code-review
难度 1/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
component:sight
难度 2/5 1-3 小时 新手友好度 84/100
agentic-os-org/ANOLISA#4115 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
rivet-dev/rivet#5819 · 1 条评论 ·
维护者通常 1 天内回复
-
A-io-database bug needs triage python
难度 2/5 1-3 小时 新手友好度 86/100
维护者通常 1 天内回复