What you'll learn

A .NET project can reference a handful of packages directly while NuGet resolves many more transitive dependencies for its target frameworks. The resolved package graph is the inventory that dependency auditing examines; it is not a list of assemblies proven to load at runtime.

NuGet dependency auditing combines inventory, known-advisory checks, and maintenance review. NuGet Audit runs during restore in supported SDK and NuGet versions. Its results depend on the resolved graph, configured audit scope, and advisory data available at that time.

This article shows how to inspect direct and transitive package references, review known advisories, check deprecation and version status, and make configured audit findings visible in continuous integration.

Why it matters

Why Transitive Dependencies Need Review

A project file shows direct references, while dotnet package list --include-transitive reports the resolved package graph for the selected projects and target frameworks. Some resolved packages may not be loaded by a particular execution path, but they still deserve review because they can contribute code or assets to the application.

A direct dependency is one your project references explicitly. A transitive dependency arrives through another package. Both affect restore and build results, and ownership of a transitive package can be less obvious, so include it in routine review.

An advisory is a signal to investigate, not proof that a vulnerable code path is reachable or that an incident will occur. Check the affected version range, where the package is used, available remediations, and your application's context. Treat transitive findings with the same care as direct findings.

The Three Dimensions of Dependency Risk

Review these separate dependency signals:

  • Vulnerability advisories: NuGet Audit reports known advisories for packages in the restored graph. Coverage depends on the configured advisory sources and their data; an empty report does not establish that all package risks are absent.
  • Deprecation: A package maintainer has marked the package as deprecated, often with a reason or alternative. Deprecation is a maintenance signal, but does not by itself establish whether the package receives security fixes.
  • Staleness: A newer version is available. That alone does not mean the current version is unsafe; review release notes, support status, and compatibility before planning an update.

NuGet CLI commands help review these separate signals. They do not replace advisory triage or compatibility testing.

Implementation

Step 1: Inventory Your Full Dependency Tree

Run this command from the project or solution root to inspect resolved direct and transitive package references for the selected target frameworks. These examples use the .NET 10 SDK command form; with .NET 9 and earlier, restore first and use dotnet list package followed by the same options:

Shell


# List only direct dependencies
dotnet package list

# Include transitive references in the resolved restore graph
dotnet package list --include-transitive

# Output as JSON for tooling integration
dotnet package list --include-transitive --format json
            

The output separates Top-level Package from Transitive Package. Review the Resolved version: it records NuGet's selection for that restore, which can differ from the requested range.

Text


Project 'OrderApi' has the following package references

   [net10.0]:
   Top-level Package:
                         Requested   Resolved
   > Dapper              2.1.35      2.1.35
   > FluentValidation    11.10.0     11.10.0
   > Polly               8.5.2       8.5.2

   Transitive Package:
                                    Resolved
   > Microsoft.Bcl.AsyncInterfaces  9.0.4
   > System.Threading.Tasks.Extensions 4.5.4
   ... (50+ more entries)
            

Step 2: Find Vulnerable Packages With NuGet Audit

Supported NuGet versions run NuGet Audit during dotnet restore and report known advisories for the restored package graph. The default audit scope can vary with NuGet version and target framework, so configure it explicitly when you need transitive coverage. You can also query package findings. The --vulnerable command uses configured audit sources starting with .NET SDK 9.0.300; earlier versions use package sources:

Shell


# Report vulnerable packages (direct only, by default)
dotnet package list --vulnerable

# Include transitive packages in the vulnerability scan
dotnet package list --vulnerable --include-transitive
            

The output identifies each vulnerable package, its severity level, and a link to the advisory:

Text


Project 'OrderApi' has the following vulnerable packages

   [net10.0]:
   Top-level Package:
                         Requested   Resolved   Severity   Advisory URL
   > SomeOldPackage       1.2.0       1.2.0      High       https://github.com/advisories/GHSA-xxxx-yyyy-zzzz

   Transitive Package:
                                    Resolved   Severity   Advisory URL
   > AnotherTransitivePkg  3.1.0      High       https://github.com/advisories/GHSA-aaaa-bbbb-cccc
            

Severity labels help prioritize triage; they do not measure reachability in your application. Review the advisory and affected version range, then assess remediation for both direct and transitive packages.

Step 3: Configure NuGet Audit in Your Build

Audit warnings are produced during restore. Set the scope and severity threshold explicitly, then promote the relevant NuGet audit warning codes to errors if your policy requires CI to fail on findings. A root Directory.Build.props can apply these MSBuild properties across projects:

XML


<!-- Directory.Build.props — place at your solution root, applies to all projects -->
<Project>
  <PropertyGroup>
    <!-- Include direct and transitive packages regardless of SDK defaults -->
    <NuGetAuditMode>all</NuGetAuditMode>
    <!-- Set the minimum severity according to your team's policy -->
    <NuGetAuditLevel>high</NuGetAuditLevel>
    <!-- Fail on audit findings without changing unrelated warning policy -->
    <WarningsAsErrors>$(WarningsAsErrors);NU1900;NU1901;NU1902;NU1903;NU1904;NU1905</WarningsAsErrors>
  </PropertyGroup>
</Project>
            

NuGetAuditMode set to all requests direct and transitive auditing. The WarningsAsErrors list promotes the audit diagnostics to errors without turning every compiler or analyzer warning into a failure. This example promotes NU1905 if NuGet emits it. That diagnostic indicates a configured audit source does not provide vulnerability data; when no auditSources are configured, NuGet uses package sources and suppresses NU1905. The other listed diagnostics cover audit-data retrieval errors and advisory findings. With the high threshold, the policy blocks high and critical findings. Choose the severity threshold deliberately.

You can override these solution-wide defaults per-project in the .csproj file, which is useful when different projects in a solution have different risk tolerances:

XML


<PropertyGroup>
  <!-- Enable or disable audit for this specific project -->
  <NuGetAudit>true</NuGetAudit>

  <!-- Minimum severity that triggers a warning: low, moderate, high, critical -->
  <NuGetAuditLevel>moderate</NuGetAuditLevel>

  <!-- Audit direct packages only, or all (includes transitive) -->
  <NuGetAuditMode>all</NuGetAuditMode>
</PropertyGroup>
            

Audit runs when restore evaluates the graph. A later dotnet build --no-restore does not repeat that audit, so ensure CI runs restore with the intended configuration. A clean audit means no matching advisory was reported for that graph and data source; it is not a complete security assessment.

Step 4: Detect Deprecated Packages

NuGet package metadata can identify packages their authors marked as deprecated. Treat the result as a maintenance signal and review the stated reason and suggested alternative:

Shell


# Direct deprecated packages
dotnet package list --deprecated

# Include transitive
dotnet package list --deprecated --include-transitive
            
Text


Project 'OrderApi' has the following deprecated packages

   [net10.0]:
   Transitive Package:
                                Resolved   Reason(s)         Alternative
   > OldAuthLibrary             2.0.1      Legacy, Critical  NewAuthLibrary
   > UnmaintainedHelper         1.5.0      Legacy            (none suggested)
            

The output can include a deprecation reason and a suggested alternative. Verify those details against the package's release notes and support policy before choosing a replacement.

Step 5: Identify Outdated Packages

Outdated means a newer version is available; it does not necessarily mean the current version is vulnerable or still supported. Use the list to plan updates and compare release notes:

Shell


dotnet package list --outdated

# Include transitive packages that have newer versions available
dotnet package list --outdated --include-transitive
            
Text


Project 'OrderApi' has the following updates available

   [net10.0]:
   Top-level Package:
                     Requested   Resolved   Latest
   > Dapper           2.1.35      2.1.35     2.1.44
   > FluentValidation 11.10.0     11.10.0    11.11.0

   Transitive Package:
                                    Resolved   Latest
   > System.Text.Json               8.0.5      10.0.1
            

The Latest column is a point-in-time comparison. For a transitive package, first look for an upstream update. An explicit reference can influence resolution, but check compatibility and dependency constraints before using it as a temporary override.

Step 6: Override a Vulnerable Transitive Dependency

If the upstream package has not yet released a fix, a direct reference may select a patched transitive version when the package APIs and dependency constraints remain compatible. Treat this as a temporary remediation and verify the resulting restore graph and tests:

XML


<ItemGroup>
  <!-- Example only: use a verified, compatible patched version -->
  <PackageReference Include="Some.Transitive.Package" Version="4.2.1" />
</ItemGroup>
            

NuGet resolution and compatibility rules still apply; an override can introduce a downgrade warning or runtime incompatibility. Inspect the resolved graph, run regression tests, document the reason, and remove the override when an upstream fix is available.

Putting It All Together: A CI Health Check Script

Use inventory commands for review and let restore's configured audit diagnostics provide the CI gate. The commands below report separate signals; they do not by themselves guarantee a nonzero exit code when findings appear:

Shell


dotnet restore
dotnet package list --vulnerable --include-transitive
dotnet package list --deprecated --include-transitive
dotnet package list --outdated --include-transitive
            

Run these commands from a solution root in your CI environment. Do not parse human-readable output with a fixed grep pattern to decide whether findings exist; output formats can change. Configure NuGet audit diagnostics as errors for a reliable restore gate, and retain the lists as triage information.

Understanding the Vulnerability Pipeline

The audit result depends on the package graph and advisory data available when restore runs:

Text


Resolved package graph
        │
        ▼
NuGet Audit checks configured advisory data
        │
        ▼
Restore reports matching findings
        │
        ▼
Developer reviews scope, remediation, and regression tests
            

Advisory publication and feed refresh are not instantaneous or guaranteed to meet a fixed interval. Run restore regularly and keep the SDK and package sources current, while recognizing that audits only identify known advisories represented in the data available to NuGet.

Summary

Dependency auditing gives teams a repeatable view of resolved packages and known advisories. Keep these limits and actions in mind:

  • dotnet package list --include-transitive reports resolved direct and transitive references for selected projects and target frameworks; it does not prove which assemblies load at runtime.
  • NuGet Audit is integrated into supported SDK/NuGet restore workflows. Confirm the SDK version, advisory sources, and configured direct/transitive scope used by CI.
  • Vulnerability, deprecation, and outdated-package reports are different signals. Review each with advisory details, maintenance status, compatibility, and project context.
  • Configure NuGetAuditLevel, NuGetAuditMode, and audit warning handling in Directory.Build.props or project files.
  • A temporary direct reference can select a patched transitive version when compatible; verify the resolved graph, test the application, and remove the override when upstream support lands.

Use audit findings to prioritize remediation, then verify the fix with restore and regression tests. A clean report is useful evidence about known advisories, not proof that a dependency graph is risk-free.

For a remediation workflow that keeps package details out of domain code, see Swap Out a Vulnerable NuGet Package Without Touching Your Domain Code in .NET.