Dependency vulnerability scanning in .NET 10: NuGetAudit settings (mode, level, sources, suppressions), turning NU1903/NU1904 into errors, dotnet list package --vulnerable with JSON output, Dependabot configuration, and a risk-based build policy with time-boxed exceptions.
I use NuGetAudit, which runs during dotnet restore and reports known vulnerabilities as NU1901-NU1904 (low to critical). With the .NET 10 SDK, net10.0 projects audit transitive packages by default (NuGetAuditMode=all). For policy, I set WarningsAsErrors for NU1903 and NU1904 in CI so high and critical findings fail the build, while low and moderate stay as warnings with tickets. Reviewed false positives get a NuGetAuditSuppress entry with the advisory URL and a recorded expiry. dotnet list package --vulnerable --include-transitive --format json feeds reports. Dependabot opens grouped upgrade PRs and security updates. If restore uses only a private feed, I add <auditSources> pointing at nuget.org. And I scan container images separately. Trade-off: strict gates on transitive findings can block a release for an unreachable code path, so exceptions must be quick, visible and time-boxed.
"For .NET the starting point is NuGetAudit, because it's built into restore: no extra tool, and it runs on every developer machine and every CI build. It checks the resolved package graph against vulnerability data from nuget.org, which comes from the GitHub Advisory Database, and raises NU1901 to NU1904 for low, moderate, high and critical. In the .NET 10 SDK, projects targeting net10.0 audit transitive packages by default, which is important because most vulnerable packages arrive transitively - a
System.Text.JsonorAzure.Identityversion pulled in by something else.The policy question is what fails the build. I don't turn every warning into an error, because a moderate advisory in a transitive test dependency shouldn't block a hotfix. So in CI I set
WarningsAsErrorstoNU1903;NU1904: high and critical fail. Low and moderate show up as warnings, get a ticket, and must be fixed within a set time. When we've reviewed an advisory and it genuinely doesn't apply, we addNuGetAuditSuppresswith the advisory URL, plus a comment with who reviewed it and a review date, so suppressions are visible in code review. To fix transitive findings I upgrade the parent package, or with Central Package Management I pin the transitive version centrally. Dependabot opens grouped weekly PRs and immediate security PRs, anddotnet list package --vulnerable --include-transitive --format jsongives me a report for dashboards.The mistake I see is suppressing NU1903 globally with
NoWarnbecause one advisory was noisy, which silently hides every future one too. Another is restoring only from a private feed with no audit source, so NuGetAudit has no data and says nothing. The senior point is that the gate is a policy: severity thresholds, time-to-fix targets, and explicit, expiring exceptions."
| Property | Values | Default (.NET 10 SDK) | Use |
|---|---|---|---|
NuGetAudit |
true/false | true | Turn auditing on or off |
NuGetAuditMode |
direct / all | all for net10.0+, direct for older TFMs | Include transitive packages |
NuGetAuditLevel |
low / moderate / high / critical | low | Minimum severity reported |
NuGetAuditSuppress (item) |
advisory URL | none | Suppress one reviewed advisory |
<auditSources> (nuget.config) |
source URLs | package sources | Vulnerability data when restoring from private feeds |
WarningsAsErrors |
NU1903;NU1904 | none | Fail on high/critical |
| Severity | Build behaviour | Fix within | Exception |
|---|---|---|---|
| Critical (NU1904) | Fails CI | 48 hours / before release | Security lead approval, max 7 days |
| High (NU1903) | Fails CI | 7 days | Tech lead approval, max 30 days |
| Moderate (NU1902) | Warning + ticket | 30 days | Team decision |
| Low (NU1901) | Warning | Next routine upgrade | Not needed |
After retargeting [12] services to net10.0, transitive auditing surfaced [37] warnings, [4] of them high. Pinning two transitive packages in Directory.Packages.props and upgrading [Azure SDK] packages cleared the highs in [one sprint], and the CI gate has since blocked [N] merges that would have introduced high-severity packages.
Checks whether the candidate can configure built-in .NET vulnerability scanning and design a build policy that teams will actually keep.
Green flags
WarningsAsErrors, suppresses per advisory.Red flags
NoWarn for audit warnings. GitHub Advisory Database (reviewed advisories for the NuGet ecosystem)
|
v
nuget.org vulnerability resource (part of the V3 service index)
| downloaded and cached by the NuGet client during restore
v
dotnet restore -> resolves the full graph -> matches id + version ranges
|
v
NU1901 low | NU1902 moderate | NU1903 high | NU1904 critical
NU1900 = couldn't fetch vulnerability data (network, source)
If your only package source is a private feed that doesn't provide the vulnerability resource, add nuget.org as an audit source so restore can still get the data without restoring packages from it.
Claims.Api
|- Azure.Identity 1.10.0 (direct)
| |- Microsoft.Identity.Client 4.56.0 (transitive) <- vulnerable
|- Contoso.Reporting 2.1.0 (direct, internal)
|- System.Text.Json 8.0.0 (transitive) <- vulnerable
Fix options, in order of preference:
PackageReference to the fixed transitive version (works, but clutters projects).CentralPackageTransitivePinningEnabled and list the fixed version in Directory.Packages.props.The .NET 10 SDK also prunes package references that the shared framework already provides, which removes many false positives from old framework packages.
TreatWarningsAsErrors=true makes audit warnings errors too; if you use it, decide whether you want low/moderate to fail (usually not) and use WarningsNotAsErrors for NU1901;NU1902.WarningsAsErrors with NU1903;NU1904, conditioned on CI so local restores don't block offline development.NoWarn for audit codes hides all future advisories of that severity. Prefer NuGetAuditSuppress per advisory.dotnet list package --vulnerable --include-transitive prints vulnerable packages per project and TFM.--format json --output-version 1 produces machine-readable output for dashboards or a PR comment.dotnet package list is the noun-first form of the same command.dependabot.yml) open routine upgrade PRs; use groups to bundle related packages (e.g. all Microsoft.Extensions.*) and avoid PR floods.| Component | Scanner |
|---|---|
| Container base images (OS packages) | Microsoft Defender for Containers, Trivy, Grype |
| npm packages in a SPA | npm audit, Dependabot |
| GitHub Actions | Dependabot (github-actions ecosystem) |
| IaC (Bicep/Terraform) | Checkov, PSRule for Azure, Defender for DevOps |
| Your own code | CodeQL / SAST |
"Patch applications" expects vulnerabilities in internet-facing applications to be patched quickly, with tighter time frames when exploits exist, and the use of vulnerability scanners to identify missing patches. A severity-based CI gate with defined fix times is how a .NET team provides that evidence for its own dependencies.
dotnet restore; read the NU190x warning and the advisory URL.NuGetAuditMode between direct and all and compare results.WarningsAsErrors for NU1903;NU1904 under a CI condition, and run dotnet build -p:CI=true.NuGetAuditSuppress and confirm only that one disappears.dotnet list package --vulnerable --include-transitive --format json and pipe it to jq to count findings by severity.Directory.Build.props: audit transitive packages everywhere, fail CI on high and critical only:
<Project>
<PropertyGroup>
<NuGetAudit>true</NuGetAudit>
<NuGetAuditMode>all</NuGetAuditMode> <!-- default for net10.0; explicit for older TFMs -->
<NuGetAuditLevel>low</NuGetAuditLevel> <!-- report everything -->
</PropertyGroup>
<!-- Gate in CI only, so developers can still restore offline or mid-upgrade. -->
<PropertyGroup Condition="'$(CI)' == 'true'">
<WarningsAsErrors>$(WarningsAsErrors);NU1903;NU1904</WarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<!-- Reviewed 2026-11-12 by [name]: vulnerable API not used (we never call X). Re-review by 2027-02-12. -->
<NuGetAuditSuppress Include="https://github.com/advisories/GHSA-xxxx-xxxx-xxxx" />
</ItemGroup>
</Project>
Directory.Packages.props: pin a vulnerable transitive package to a fixed version centrally:
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Azure.Identity" Version="1.17.0" />
<!-- Transitive pin: overrides the older version pulled in by an internal package. -->
<PackageVersion Include="System.Text.Json" Version="10.0.0" />
</ItemGroup>
</Project>
nuget.config: keep vulnerability data available when packages come only from a private feed:
<configuration>
<packageSources>
<clear />
<add key="contoso" value="https://pkgs.dev.azure.com/contoso/_packaging/internal/nuget/v3/index.json" />
</packageSources>
<auditSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</auditSources>
</configuration>
CI: restore (which audits), then publish a JSON report; .github/dependabot.yml for grouped updates:
# workflow steps
- run: dotnet restore --locked-mode -p:CI=true # fails on NU1903/NU1904
- run: dotnet list package --vulnerable --include-transitive --format json > vulnerable.json
- uses: actions/upload-artifact@v4
with: { name: vulnerability-report, path: vulnerable.json }
# .github/dependabot.yml
version: 2
updates:
- package-ecosystem: nuget
directory: /
schedule: { interval: weekly }
groups:
microsoft-extensions: { patterns: ["Microsoft.Extensions.*"] }
azure-sdk: { patterns: ["Azure.*"] }
- package-ecosystem: github-actions
directory: /
schedule: { interval: weekly }
NoWarn because one advisory was noisy. Why it is wrong: It hides every future advisory at those levels across the project. Instead: Suppress the single advisory with NuGetAuditSuppress, with a reason and review date.NuGetAuditMode=all explicitly for pre-net10.0 projects.<auditSources>.The tooling is easy; the policy is the senior part. A good policy is severity-based, has fix-time targets tied to the Essential Eight's patching expectations, makes exceptions cheap but visible (a suppression in code review with an expiry), and gives someone the job of looking at the trend. Without that, either the gate blocks releases on irrelevant findings and gets disabled, or warnings accumulate until nobody reads them.
Reachability matters but is expensive to prove; default to upgrading, and only argue "not reachable" for a suppression when an upgrade is genuinely blocked. Measure: open high/critical findings across services, median time to fix by severity, number of active suppressions past their review date, and Dependabot PR age.
| Tool | When it fits | Cost | When not to rely on it alone |
|---|---|---|---|
| NuGetAudit in restore | Every .NET project | Free, built in | Malicious packages, non-NuGet components |
dotnet list package --vulnerable |
Reports, dashboards, ad-hoc checks | Free | As the only gate (it doesn't fail builds by itself) |
| Dependabot / Renovate | Keeping dependencies current, auto PRs | PR volume | Without grouping and an owner, PRs rot |
| Container image scanning | Anything shipped as an image | Licence or Defender cost | Doesn't see NuGet packages compiled into your app consistently |
Supply chain security protects everything that goes into your build, not just your own code. The attacks: typosquatting (Newtonsof.Json), dependency confusion (a public package with your internal name), compromised maintainers or packages, and compromised build systems or CI actions. NuGet packages are dangerous because their MSBuild targets and analysers run code during build. My controls: package source mapping so each package id comes only from its intended feed, lock files with --locked-mode, signature validation with trusted signers where it fits, an internal feed with upstreams as a single entry point, and NuGetAudit for known vulnerabilities. For what we ship: an SBOM for every build and signed provenance attestations proving which commit and pipeline produced the artefact, aiming at SLSA build levels. Trade-off: every control adds friction to adding a dependency, which is partly the point.
First I read the exact error. NU1301 means a source couldn't be reached, 401 or 403 means authentication, and NU1101 means the package isn't on any configured source. It works on my machine because I have cached packages and stored credentials, while CI starts clean. Then I check which nuget.config CI actually uses, since config files are merged from the repo upwards. I make the repo's config explicit with <clear />, and I authenticate CI the supported way, for example the Azure Artifacts credential provider or a token from the pipeline's secret store, never a committed password. I also add package source mapping and lock files so restores are reproducible and protected against dependency confusion.
First check whether a fixed version of the transitive package itself exists and is compatible: if so, pin it with Central Package Management transitive pinning (or a direct reference) and run the tests. If not, assess reachability and exposure: do we call the vulnerable API or code path, with untrusted input, in an internet-facing service? Then apply package-level mitigations: avoid the vulnerable API, wrap it with validation, disable the feature that uses it, or swap to an alternative library. Tell stakeholders (product owner, security lead) the risk, the mitigation and the plan in plain terms. Suppress only that advisory with NuGetAuditSuppress, a short expiry and security-lead approval, and track the upstream issue. If it's reachable, unmitigable and no fix is coming, replace the package. Longer term, a scheduled review of transitive dependencies and fewer heavyweight dependencies reduce how often this happens.
How to tell it (STAR)
**S:** We retargeted [12] services to .NET 10, and transitive auditing broke every pipeline with vulnerability warnings for packages we'd never referenced directly. **T:** People wanted to suppress them all; I wanted a gate we'd actually keep. **A:** I aggregated findings with dotnet list package, set the policy to fail only on high and critical, fixed the highs by upgrading the Azure SDK and pinning two transitive packages centrally, and added a single time-boxed suppression for an advisory with no fix. **R:** Highs went from [4] to [0] within [a sprint], pipelines were green without blanket suppressions, and the gate has since blocked [N] merges that would have added high-severity packages.
Last updated 23 Nov 2026.