Skip to content

Commit f3f03f6

Browse files
authored
Merge pull request #43569 from dotnet/net9-nuget-breaking-change
Add .NET 9 breaking change about NuGetAuditMode changed default
2 parents 1abbdcd + e40f32f commit f3f03f6

File tree

3 files changed

+69
-6
lines changed

3 files changed

+69
-6
lines changed

docs/core/compatibility/9.0.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,12 @@ If you're migrating an app to .NET 9, the breaking changes listed here might aff
9595

9696
| Title | Type of change | Introduced version |
9797
|-------------------------------------------------------------------------------|-------------------|--------------------|
98-
| [`dotnet watch` incompatible with Hot Reload for old frameworks](sdk/9.0/dotnet-watch.md) | Behavioral change | RC 1 |
98+
| [`dotnet restore` audits transitive packages](sdk/9.0/nugetaudit-transitive-packages.md) | Behavioral change | Preview 6 |
99+
| [`dotnet watch` incompatible with Hot Reload for old frameworks](sdk/9.0/dotnet-watch.md) | Behavioral change | RC 1 |
99100
| [`dotnet workload` commands output change](sdk/9.0/dotnet-workload-output.md) | Behavioral change | Preview 1 |
100101
| [`installer` repo version no longer documented](sdk/9.0/productcommits-versions.md) | Behavioral change | Preview 5 |
101102
| [Terminal logger is default](sdk/9.0/terminal-logger.md) | Behavioral change | Preview 1 |
102-
| [Version requirements for .NET 9 SDK](sdk/9.0/version-requirements.md) | Source incompatible | GA |
103+
| [Version requirements for .NET 9 SDK](sdk/9.0/version-requirements.md) | Source incompatible | GA |
103104
| [Warning emitted for .NET Standard 1.x target](sdk/9.0/netstandard-warning.md) | Source incompatible | Preview 6 |
104105
| [Warning emitted for .NET 7 target](sdk/9.0/net70-warning.md) | Source incompatible | GA |
105106

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
title: "Breaking change: 'dotnet restore' audits transitive packages"
3+
description: Learn about a breaking change in the .NET 9 SDK where 'dotnet restore' also produces security vulnerability warnings for transitive packages by default.
4+
ms.date: 11/14/2024
5+
---
6+
# 'dotnet restore' audits transitive packages
7+
8+
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.
9+
10+
## Previous behavior
11+
12+
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.
13+
14+
## New behavior
15+
16+
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.
17+
If your project treats errors as warnings, this behavior can cause restore failures.
18+
19+
## Version introduced
20+
21+
.NET 9 Preview 6
22+
23+
## Type of breaking change
24+
25+
This change is a [behavioral change](../../categories.md#behavioral-change).
26+
27+
## Reason for change
28+
29+
Packages with known vulnerabilities might cause your app to be exploitable, even if your project does not directly reference or use the vulnerable package.
30+
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.
31+
32+
## Recommended action
33+
34+
- 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.
35+
36+
- 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.
37+
38+
- 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.
39+
40+
```xml
41+
<ItemGroup>
42+
<NuGetAuditSuppress Include="url" />
43+
</ItemGroup>
44+
```
45+
46+
- If you want to only be warned of direct package references with known vulnerabilities, you can set `<NuGetAuditMode>` to `direct` in your project file.
47+
48+
```xml
49+
<PropertyGroup>
50+
<NuGetAuditMode>direct</NuGetAuditMode>
51+
</PropertyGroup>
52+
```
53+
54+
## See also
55+
56+
- [Audit for security vulnerabilities (`dotnet restore`)](../../../tools/dotnet-restore.md#audit-for-security-vulnerabilities)
57+
- [Auditing package dependencies for security vulnerabilities](/nuget/concepts/auditing-packages)
58+
- [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/)

docs/core/compatibility/toc.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,13 @@ items:
9494
href: networking/9.0/query-redaction-logs.md
9595
- name: SDK and MSBuild
9696
items:
97+
- name: "`dotnet restore` audits transitive packages"
98+
href: sdk/9.0/nugetaudit-transitive-packages.md
9799
- name: "`dotnet watch` incompatible with Hot Reload for old frameworks"
98100
href: sdk/9.0/dotnet-watch.md
99-
- name: "'dotnet workload' commands output change"
101+
- name: "`dotnet workload` commands output change"
100102
href: sdk/9.0/dotnet-workload-output.md
101-
- name: "'installer' repo version no longer documented"
103+
- name: "`installer` repo version no longer documented"
102104
href: sdk/9.0/productcommits-versions.md
103105
- name: Terminal logger is default
104106
href: sdk/9.0/terminal-logger.md
@@ -1776,11 +1778,13 @@ items:
17761778
items:
17771779
- name: .NET 9
17781780
items:
1781+
- name: "`dotnet restore` audits transitive packages"
1782+
href: sdk/9.0/nugetaudit-transitive-packages.md
17791783
- name: "`dotnet watch` incompatible with Hot Reload for old frameworks"
17801784
href: sdk/9.0/dotnet-watch.md
1781-
- name: "'dotnet workload' commands output change"
1785+
- name: "`dotnet workload` commands output change"
17821786
href: sdk/9.0/dotnet-workload-output.md
1783-
- name: "'installer' repo version no longer documented"
1787+
- name: "`installer` repo version no longer documented"
17841788
href: sdk/9.0/productcommits-versions.md
17851789
- name: Terminal logger is default
17861790
href: sdk/9.0/terminal-logger.md

0 commit comments

Comments
 (0)