📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

Show how you set up dependency vulnerability scanning for a .NET 10 solution. Cover NuGetAudit during restore, dotnet list package --vulnerable, Dependabot, and how you fail the build according to a policy without blocking every developer on low-severity issues.

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.

Mid-Level Coding Intermediate ci-cd dependabot dependency-scanning nuget nugetaudit security

🎯 Key points

  • NuGetAudit runs during restore using the GitHub Advisory Database via nuget.org's vulnerability data; warnings NU1901 (low) to NU1904 (critical), NU1900 if data can't be fetched
  • .NET 10 SDK: NuGetAuditMode defaults to all (transitive) only for projects targeting net10.0 or later; projects on older TFMs still default to direct unless you set it
  • Policy via MSBuild: WarningsAsErrors for NU1903;NU1904 in CI, NuGetAuditSuppress per reviewed advisory with a recorded review date
  • Never NoWarn the NU190x codes: that silences every future advisory at that severity across the project, so new vulnerable packages ship unnoticed
  • dotnet list package --vulnerable --include-transitive --format json for reports and dashboards
  • Dependabot (or Renovate) opens grouped upgrade PRs and immediate security PRs; fix transitive issues by upgrading the parent or Central Package Management transitive pinning
  • Add <auditSources> when restoring only from a private feed; scan container images separately (Defender for Containers, Trivy)
  • Scanning covers known CVEs only; it is one part of a supply chain policy alongside source mapping, lock files, provenance and fix-time targets tied to the Essential Eight's patching expectations

⏱ 30-second answer

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.

🗣 Full answer (senior)

How I would answer this in an interview

"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.Json or Azure.Identity version 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 WarningsAsErrors to NU1903;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 add NuGetAuditSuppress with 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, and dotnet list package --vulnerable --include-transitive --format json gives me a report for dashboards.

The mistake I see is suppressing NU1903 globally with NoWarn because 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."


NuGetAudit settings

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

A practical policy

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

Production example

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.

🔍 What the interviewer is checking

Checks whether the candidate can configure built-in .NET vulnerability scanning and design a build policy that teams will actually keep.

Green flags

  • Knows NuGetAudit codes, transitive mode and the .NET 10 default.
  • Fails on high/critical with WarningsAsErrors, suppresses per advisory.
  • Fixes transitive issues properly (parent upgrade, CPM pinning).
  • Mentions audit sources for private feeds and container scanning.
  • Talks about policy: fix times, exceptions, ownership.

Red flags

  • Global NoWarn for audit warnings.
  • Only knows Dependabot, not restore-time audit.
  • Fails the build on everything, or nothing.

📚 Learn in depth

1. Where the vulnerability data comes from

 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.

2. Direct versus transitive

 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:

  1. Upgrade the direct parent to a version that depends on a fixed version.
  2. Add a direct PackageReference to the fixed transitive version (works, but clutters projects).
  3. With Central Package Management, set CentralPackageTransitivePinningEnabled and list the fixed version in Directory.Packages.props.
  4. If no fix exists: assess reachability, mitigate, suppress with an expiry.

The .NET 10 SDK also prunes package references that the shared framework already provides, which removes many false positives from old framework packages.

3. Turning warnings into a gate

  • 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.
  • More targeted: 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.

4. dotnet list package

  • 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.
  • In newer SDKs, dotnet package list is the noun-first form of the same command.
  • It uses the same sources and vulnerability data, so it agrees with restore.

5. Dependabot

  • Dependabot alerts use GitHub's dependency graph (which understands lock files and project files) and the Advisory Database.
  • Dependabot security updates open PRs to fix alerts automatically.
  • Version updates (dependabot.yml) open routine upgrade PRs; use groups to bundle related packages (e.g. all Microsoft.Extensions.*) and avoid PR floods.
  • Renovate is an alternative with richer grouping and scheduling.

6. Beyond NuGet

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

7. Essential Eight link

"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.

Try it yourself

  1. Add a known-vulnerable version of a package (check the GitHub Advisory Database for one) to a test project and run dotnet restore; read the NU190x warning and the advisory URL.
  2. Switch NuGetAuditMode between direct and all and compare results.
  3. Add WarningsAsErrors for NU1903;NU1904 under a CI condition, and run dotnet build -p:CI=true.
  4. Suppress one advisory with NuGetAuditSuppress and confirm only that one disappears.
  5. Run dotnet list package --vulnerable --include-transitive --format json and pipe it to jq to count findings by severity.

💻 Code

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 }

⚠ Common mistakes

  • Mistake: Adding NU1901-NU1904 to 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.
  • Mistake: Auditing only direct references on older target frameworks. Why it is wrong: Most vulnerable packages arrive transitively. Instead: Set NuGetAuditMode=all explicitly for pre-net10.0 projects.
  • Mistake: Restoring only from a private feed and assuming audit works. Why it is wrong: Without a source that provides vulnerability data, restore reports nothing (or NU1900). Instead: Add nuget.org under <auditSources>.
  • Mistake: Failing the build on every severity from day one. Why it is wrong: Teams get blocked on low-risk findings and start suppressing everything. Instead: Fail on high and critical, track moderate and low with time-to-fix targets.
  • Mistake: Fixing a transitive vulnerability by adding direct references in every project. Why it is wrong: It clutters projects and the pins rot. Instead: Upgrade the parent, or use Central Package Management transitive pinning.
  • Mistake: Letting Dependabot PRs pile up unmerged. Why it is wrong: The backlog becomes unmanageable and security fixes get lost among routine bumps. Instead: Group updates, schedule them, and fast-track security PRs.
  • Mistake: Scanning NuGet packages but not container images. Why it is wrong: OS packages in base images carry many of the critical CVEs. Instead: Scan images in the registry and rebuild regularly on patched base images.
  • Mistake: Treating zero warnings as "secure". Why it is wrong: Scanners only find known, published vulnerabilities, not malicious packages. Instead: Combine with supply chain controls (source mapping, lock files, provenance).

🏛 Senior insight: trade-offs

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

🔗 Follow-ups the interviewer may ask

  1. When: Candidate says scanning keeps dependencies secure. Why: Checks the candidate understands what vulnerability scanning doesn't cover: malicious packages and compromised builds.
    How to answer

    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.

  2. When: Candidate mentions private feeds or audit sources. Why: Checks restore configuration in CI, including feeds and credentials, where audit runs.
    How to answer

    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.

  3. When: Candidate describes upgrading the parent package as the fix. Why: Checks judgement when the easy fix isn't available: pinning, reachability, mitigation and time-boxed exceptions.
    How to answer

    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.

🛠 Real-world problems: how you handle them

Transitive audit after retargeting to .NET 10 floods CI with warnings
Situation
[A team of 8] maintaining [12] ASP.NET Core services retargeted from net8.0 to net10.0 ahead of [.NET 8 end of support]. CI used TreatWarningsAsErrors.
Signals
Every pipeline failed after the retarget with NU1902 and NU1903 errors for packages nobody had referenced directly; developers started proposing `NoWarn` for all NU190x codes.
Investigation
Ran `dotnet list package --vulnerable --include-transitive --format json` across the solutions and aggregated by package; found [37] findings from [6] distinct transitive packages, mostly pulled in by older Azure SDK and an internal reporting package. Checked each advisory's affected ranges and fixed versions on the GitHub Advisory Database.
Resolution
Immediate: changed the gate to fail only on NU1903/NU1904 and kept the rest as warnings with tickets, rather than suppressing everything. Then upgraded Azure SDK packages, enabled CPM transitive pinning for two packages, and released a new internal reporting package version. One advisory with no fix got a `NuGetAuditSuppress` entry with a 60-day review date.
Prevention
Documented severity policy and fix times, Dependabot grouped updates, a weekly vulnerability report artefact, and a CI check that flags suppressions past their review date.

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.

↩ Usually asked after

More in Senior Security Topics

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me