A .NET app that carries its own runtime, and lists a hundred packages it never ships

.NET 6 console app published self-contained: the runtime ships inside the artefact as a NuGet package

Test case
dotnet-selfcontained
Ecosystems
nuget
Scanned at
source, artefact, image

The application and how it is built

A .NET 6 console app with three old NuGet libraries: Newtonsoft.Json, log4net and SharpZipLib. The project file also references three System.* packages and a Roslyn analyzer. It's published self-contained, so the output folder holds the app, its libraries and the whole .NET 6 runtime, and the image adds nothing but the native libraries the runtime needs.

What gets hidden, and how

Two things are hidden, in opposite directions. Publishing self-contained copies the .NET runtime into the output from a NuGet runtime pack, Microsoft.NETCore.App.Runtime for the build machine's platform. No file in the source tree names it; only the publish output's deps.json does. Meanwhile restore resolves about 110 packages, mostly System.* and runtime.* packages pulled in by the old libraries, and publish drops nearly all of them because .NET 6 already contains newer copies. The analyzer runs inside the compiler and ships nothing.

ComponentMechanismIn the artefact?What happens to it
Microsoft.NETCore.App.Runtime.linux-x64@6.0.36runtime-packshipsthe .NET 6 runtime itself, copied into the output by --self-contained. It comes from NuGet as a runtime pack named for the build machine (linux-x64 or linux-arm64 in the tool image), and LegacyApp.deps.json lists it with type runtimepack. No file in the source tree names it; 6.0.36 is the last public .NET 6 release
System.Text.Encodings.Web@4.5.0framework-provideddoes not shipa direct reference in the project file, but .NET 6 contains a newer copy, so publish leaves the package out. An old version with a published advisory (CVE-2021-26701), so a tool that reports it raises a finding for code that never ships

What a true SBOM would say

5 components ship, 1 of them transformed on the way in. 4 are known not to ship (1 build-tooling, 3 framework-provided). Those influence the build or run during it; a tool may list them, as long as it marks them.

The list was written by hand from the build files, the lockfiles and the listing of the built archive, and the project's own proof-check.sh asserts what ends up in the artefact. It is in expected.json, and the full list of what ships is at the foot of this page.

What the tools reported

Shipped components found, by stage

Out of 5 that ship. Only the tools that scan all three stages are drawn; the table below has every tool.

025sourceartefactimagesyft, source: 0 of 5syft, artefact: 4 of 5syft, image: 4 of 5trivy, source: 0 of 5trivy, artefact: 5 of 5trivy, image: 5 of 5cdxgen, source: 4 of 5cdxgen, artefact: 0 of 5cdxgen, image: 0 of 5trivy: 5 of 5syft: 4 of 5cdxgen: 0 of 5
syfttrivycdxgen

Component by component

Ships: Y exact version, v wrong version, p wrong group or namespace, n not named. Does not ship: L listed and marked, X listed unmarked, · not listed. A tool appears under a stage only if it was run there, so an empty column never stands for a miss. Select a cell to see what is behind it.

Select a cell.

sourceartefactimage
Componentcdxgencyclonedx-dotnetsbom-toolsyfttrivycdxgensyfttrivycdxgendocker-scoutsyfttrivy
Ships. In the artefact, including components that were shaded or bundled on the way in.
LegacyApp@*
Newtonsoft.Json@12.0.1
log4net@2.0.8
SharpZipLib@1.2.0
Microsoft.NETCore.App.Runtime.linux-x64@6.0.36 runtime-pack
Present in the build, absent from the artefact. Plugins and their payloads, imported BOMs, and dependencies the build file requires but the artefact never contains. Listing one is right when it is marked as not shipping.
System.Text.Encodings.Web@4.5.0 framework-provided

Every document

Content accuracyBaseline conformance
ToolFormatCompsIn scopeShipped foundWrong verWrong purlLeakedLabelledHashes okNTIA 2021NTIA/CISA 2026BSI v2.1
source
cdxgen 11.3.2cyclonedx88884/5008300/08.37.13.7
cyclonedx-dotnet cyclonedx87873/5008210/08.39.93.4
sbom-tool 4.1.13spdx89893/5008300/010.04.33.4
syft 1.51.0cyclonedx000/500000/03.14.44.1
trivy 0.74.0cyclonedx110/500000/03.14.44.1
artefact
cdxgen 11.3.2cyclonedx000/500000/06.78.05.7
syft 1.51.0cyclonedx554/500000/01.94.32.1
trivy 0.74.0cyclonedx765/500000/06.84.13.6
image
cdxgen 11.3.2cyclonedx15100/500000/07.66.03.0
docker-scout 1.24.0spdx14854/500000/010.06.83.7
syft 1.51.0cyclonedx10454/500000/01.84.32.1
trivy 0.74.0cyclonedx10555/500000/09.85.43.8

Details

Reading the result

Source-stage tools that read the restore graph report dozens of packages that never ship, including three with published advisories, and none of them can see the runtime. Artefact-stage tools that read deps.json see what ships, including the runtime, if they name it the way NuGet does. .NET 6 left support in November 2024, so the runtime in this artefact will never get another public fix; whether a scanner can say so depends on that one component being found and named.

This is our interpretation. The counts above are what the run recorded; why a tool found or missed something is inferred from how the tool works, not established by the data. Limits of the benchmark.

Evidence

Ground truth: what ships

ComponentNote
pkg:nuget/LegacyApp@*primary component
pkg:nuget/Newtonsoft.Json@12.0.1direct reference; Newtonsoft.Json.dll is in the output. An old version with a published advisory (CVE-2024-21907)
pkg:nuget/log4net@2.0.8direct reference; log4net.dll is in the output. Old, with a published advisory (CVE-2018-1285)
pkg:nuget/SharpZipLib@1.2.0direct reference; ships as ICSharpCode.SharpZipLib.dll, so the file name doesn't match the package name. Old, with published advisories
pkg:nuget/Microsoft.NETCore.App.Runtime.linux-x64@6.0.36the .NET 6 runtime itself, copied into the output by --self-contained. It comes from NuGet as a runtime pack named for the build machine (linux-x64 or linux-arm64 in the tool image), and LegacyApp.deps.json lists it with type runtimepack. No file in the source tree names it; 6.0.36 is the last public .NET 6 release