Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .openpublishing.redirection.core.json
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,10 @@
{
"source_path_from_root": "/docs/core/testing/unit-testing-with-nunit.md",
"redirect_url": "/dotnet/core/testing/unit-testing-csharp-with-nunit"
},
{
"source_path_from_root": "/docs/core/compatibility/sdk/9.0/nugetaudit-transitive-packages.md",
"redirect_url": "/dotnet/core/compatibility/sdk/10.0/nugetaudit-transitive-packages"
}
]
}
1 change: 1 addition & 0 deletions docs/core/compatibility/10.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ If you're migrating an app to .NET 10, the breaking changes listed here might af
| Title | Type of change | Introduced version |
|----------------------------------------------------------------------------------------------------------------------|---------------------|--------------------|
| [Default workload configuration from 'loose manifests' to 'workload sets' mode](sdk/10.0/default-workload-config.md) | Behavioral change | Preview 2 |
| [`dotnet restore` audits transitive packages](sdk/10.0/nugetaudit-transitive-packages.md) | Behavioral change | Preview 3 |
| [MSBUILDCUSTOMBUILDEVENTWARNING escape hatch removed](sdk/10.0/custom-build-event-warning.md) | Behavioral change | Preview 1 |
| [NU1510 is raised for direct references pruned by NuGet](sdk/10.0/nu1510-pruned-references.md) | Source incompatible | Preview 1 |

Expand Down
1 change: 0 additions & 1 deletion docs/core/compatibility/9.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ If you're migrating an app to .NET 9, the breaking changes listed here might aff

| Title | Type of change | Introduced version |
|-------------------------------------------------------------------------------------------|---------------------|--------------------|
| [`dotnet restore` audits transitive packages](sdk/9.0/nugetaudit-transitive-packages.md) | Behavioral change | Preview 6 |
| [`dotnet sln add` doesn't allow invalid file names](sdk/9.0/dotnet-sln.md) | Behavioral change | 9.0.2xx |
| [`dotnet watch` incompatible with Hot Reload for old frameworks](sdk/9.0/dotnet-watch.md) | Behavioral change | RC 1 |
| [`dotnet workload` commands output change](sdk/9.0/dotnet-workload-output.md) | Behavioral change | Preview 1 |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,58 +1,63 @@
---
title: "Breaking change: 'dotnet restore' audits transitive packages"
description: Learn about a breaking change in the .NET 9 SDK where 'dotnet restore' also produces security vulnerability warnings for transitive packages by default.
ms.date: 11/14/2024
---
# 'dotnet restore' audits transitive packages

The [`dotnet restore` command](../../../tools/dotnet-restore.md), which restores the dependencies and tools of a project, now produces security vulnerability warnings for transitive packages by default.

## Previous behavior

In .NET 8, [NuGetAudit](../8.0/dotnet-restore-audit.md) was introduced to emit warnings for packages with known security vulnerabilities. By default, only direct package references were audited, however, it was possible to change the `NuGetAuditMode` property to include all packages.

## New behavior

Starting in .NET 9, `NuGetAuditMode` defaults to `all` if it hasn't been explicitly set. This setting means that *transitive packages* (dependencies of packages your project directly references) with known vulnerabilities now cause warnings to be reported.
If your project treats warnings as errors, this behavior can cause restore failures.

## Version introduced

.NET 9 Preview 6

## Type of breaking change

This change is a [behavioral change](../../categories.md#behavioral-change).

## Reason for change

Packages with known vulnerabilities might cause your app to be exploitable, even if your project does not directly reference or use the vulnerable package.
New features in .NET 9 also make it easier to investigate the package graph and to suppress advisories that aren't relevant to how your app uses the vulnerable package.

## Recommended action

- To explicitly reduce the probability of this change breaking your build due to warnings, you can consider your usage of `<TreatWarningsAsErrors>` and use `<WarningsNotAsErrors>NU1901;NU1902;NU1903;NU1904</WarningsNotAsErrors>` to ensure known security vulnerabilities are still allowed in your environment.

- Use tools such as `dotnet nuget why` to find the top-level package that caused the transitive package with the known vulnerability to be included, and try to upgrade it to see if the transitive vulnerability goes away. If not, promote the transitive package to a top-level package by adding a `PackageReference` for it, and upgrade it to a newer version.

- If you want to suppress a specific advisory, you can add `<NuGetAuditSuppress Include="url" />` item to your project file, where `url` is the URL reported in NuGet's warning message.

```xml
<ItemGroup>
<NuGetAuditSuppress Include="url" />
</ItemGroup>
```

- If you want to only be warned of direct package references with known vulnerabilities, you can set `<NuGetAuditMode>` to `direct` in your project file.

```xml
<PropertyGroup>
<NuGetAuditMode>direct</NuGetAuditMode>
</PropertyGroup>
```

## See also

- [Audit for security vulnerabilities (`dotnet restore`)](../../../tools/dotnet-restore.md#audit-for-security-vulnerabilities)
- [Auditing package dependencies for security vulnerabilities](/nuget/concepts/auditing-packages)
- [NuGetAudit 2.0: Elevating Security and Trust in Package Management](https://devblogs.microsoft.com/nuget/nugetaudit-2-0-elevating-security-and-trust-in-package-management/)
---
title: "Breaking change: 'dotnet restore' audits transitive packages"
description: Learn about a breaking change in the .NET 10 SDK where 'dotnet restore' also produces security vulnerability warnings for transitive packages by default.
ms.date: 03/28/2025
---
# 'dotnet restore' audits transitive packages

The [`dotnet restore` command](../../../tools/dotnet-restore.md), which restores the dependencies of a project, now produces security vulnerability warnings for transitive packages by default when the project targets .NET 10 or a later version.

## Previous behavior

[NuGetAudit](../8.0/dotnet-restore-audit.md) was introduced in .NET 8 to emit warnings for packages with known security vulnerabilities.
By default, only direct package references were audited, however, it was possible to change the `NuGetAuditMode` property to include all packages.

In .NET 9 preview 6, NuGetAuditMode's default was changed to `all` for all projects, and this change was reverted back to `direct` in the .NET 9.0.101 SDK.

## New behavior

When projects target .NET 10 or higher, then `NuGetAuditMode` defaults to `all` if it hasn't been explicitly set.
This setting means that *transitive packages* (dependencies of packages your project directly references) with known vulnerabilities now cause warnings to be reported.
If your project treats warnings as errors, this behavior can cause restore failures.

If your project targets .NET 9 or lower, the default for `NuGetAuditMode` remains `direct`.

## Version introduced

.NET 10 Preview 3

## Type of breaking change

This change is a [behavioral change](../../categories.md#behavioral-change).

## Reason for change

Packages with known vulnerabilities might cause your app to be exploitable, even if your project does not directly reference or directly use the vulnerable package.

## Recommended action

- To prevent audit warnings being treated as errors, even when using `<TreatWarningsAsErrors>`, you can use `<WarningsNotAsErrors>NU1901;NU1902;NU1903;NU1904;$(WarningsNotAsErrors)</WarningsNotAsErrors>`.

- Use tools such as `dotnet nuget why` to find the top-level package that caused the transitive package with the known vulnerability to be included, and try to upgrade it to see if the transitive vulnerability goes away. If not, promote the transitive package to a top-level package by adding a `PackageReference` for it, and upgrade it to a newer version.

- If you want to suppress a specific advisory, you can add `<NuGetAuditSuppress Include="url" />` item to your project file, where `url` is the URL reported in NuGet's warning message.

```xml
<ItemGroup>
<NuGetAuditSuppress Include="url" />
</ItemGroup>
```

- If you want to only be warned of direct package references with known vulnerabilities, you can set `<NuGetAuditMode>` to `direct` in your project file.

```xml
<PropertyGroup>
<NuGetAuditMode>direct</NuGetAuditMode>
</PropertyGroup>
```

## See also

- [Audit for security vulnerabilities (`dotnet restore`)](../../../tools/dotnet-restore.md#audit-for-security-vulnerabilities)
- [Auditing package dependencies for security vulnerabilities](/nuget/concepts/auditing-packages)
- [NuGetAudit 2.0: Elevating Security and Trust in Package Management](https://devblogs.microsoft.com/nuget/nugetaudit-2-0-elevating-security-and-trust-in-package-management/)
8 changes: 4 additions & 4 deletions docs/core/compatibility/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ items:
href: globalization/10.0/version-override.md
- name: SDK and MSBuild
items:
- name: "`dotnet restore` audits transitive packages"
href: sdk/10.0/nugetaudit-transitive-packages.md
- name: Default workload configuration from 'loose manifests' to 'workload sets' mode
href: sdk/10.0/default-workload-config.md
- name: MSBUILDCUSTOMBUILDEVENTWARNING escape hatch removed
Expand Down Expand Up @@ -164,8 +166,6 @@ items:
href: networking/9.0/query-redaction-logs.md
- name: SDK and MSBuild
items:
- name: "`dotnet restore` audits transitive packages"
href: sdk/9.0/nugetaudit-transitive-packages.md
- name: "`dotnet sln add` doesn't allow invalid file names"
href: sdk/9.0/dotnet-sln.md
- name: "`dotnet watch` incompatible with Hot Reload for old frameworks"
Expand Down Expand Up @@ -1906,6 +1906,8 @@ items:
items:
- name: .NET 10
items:
- name: "`dotnet restore` audits transitive packages"
href: sdk/10.0/nugetaudit-transitive-packages.md
- name: Default workload configuration from 'loose manifests' to 'workload sets' mode
href: sdk/10.0/default-workload-config.md
- name: MSBUILDCUSTOMBUILDEVENTWARNING escape hatch removed
Expand All @@ -1914,8 +1916,6 @@ items:
href: sdk/10.0/nu1510-pruned-references.md
- name: .NET 9
items:
- name: "`dotnet restore` audits transitive packages"
href: sdk/9.0/nugetaudit-transitive-packages.md
- name: "`dotnet sln add` doesn't allow invalid file names"
href: sdk/9.0/dotnet-sln.md
- name: "`dotnet watch` incompatible with Hot Reload for old frameworks"
Expand Down