You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Learn about a breaking change in the .NET 9 SDK where 'dotnet restore' produces security vulnerability warnings for transitive packages by default.
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
4
5
---
5
-
# 'dotnet restore' produces security vulnerability warnings for transitive packages
6
+
# 'dotnet restore' audits transitive packages
6
7
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.
8
9
9
10
## Previous behavior
10
11
11
-
In [.NET 8, we introduced NuGetAudit](../8.0/dotnet-restore-audit.md), which emits warnings for packages with known security vulnerabilities.
12
-
It was possible to change the `NuGetAuditMode` property to include all packages, but the default was to report only direct package references.
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
13
14
14
## New behavior
15
15
16
-
`NuGetAuditMode` now defaults to `all`, if it has not been explicitly set.
17
-
This means that transitive packages (dependencies of packages your project directly references) with known vulnerabilities will now cause warnings to be reported.
18
-
If your project treats errors as warnings, this can cause restore failures.
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.
19
18
20
19
## Version introduced
21
20
@@ -28,17 +27,29 @@ This change is a [behavioral change](../../categories.md#behavioral-change).
28
27
## Reason for change
29
28
30
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.
31
-
New features in .NET 9 also make it easier to investigate the package graph, and suppress advisories that are not relevant to how your app uses 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.
32
31
33
32
## Recommended action
34
33
35
-
- To explicitly reduce the probability of this 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.
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.
36
35
37
-
- 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.
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.
38
37
39
-
- If you want to suppress a specific advisory, you can add `<NuGetAuditSuppress Include="url" />`within an `<ItemGroup>`, where `url` is the URL reported in NuGet's warning message.
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.
40
39
41
-
- If you want to only be warned of direct package references with known vulnerabilities, you can set `<NuGetAuditMode>` to `direct`.
40
+
```xml
41
+
<ItemGroup>
42
+
<NuGetAuditSuppressInclude="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.
0 commit comments