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
Copy file name to clipboardExpand all lines: docs/concepts/Auditing-Packages.md
+56-4Lines changed: 56 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,8 +16,6 @@ This involves identifying vulnerabilities, evaluating risks, and making recommen
16
16
The audit can include a review of the packages themselves, as well as any dependencies and their associated risks.
17
17
The goal of the audit is to identify and mitigate any security vulnerabilities that could be exploited by attackers, such as code injection or cross-site scripting attacks.
18
18
19
-
We also have a [blog post](https://devblogs.microsoft.com/nuget/nugetaudit-2-0-elevating-security-and-trust-in-package-management/) which discusses our recommended method for taking action when a package with a known vulnerability is found to be used by your project, and tools to help get more information.
20
-
21
19
### Feature availability
22
20
23
21
| NuGet | .NET SDK | Visual Studio | Feature |
@@ -182,7 +180,14 @@ Note that `--include-transitive` is not default, so should be included.
182
180
183
181
## Actions when packages with known vulnerabilities are reported
184
182
185
-
We also have a [blog post](https://devblogs.microsoft.com/nuget/nugetaudit-2-0-elevating-security-and-trust-in-package-management/) which discusses our recommended method for taking action when a package with a known vulnerability is found to be used by your project, and tools to help get more information.
183
+
Getting a warning about packages with known vulnerabilities is only part of the process.
184
+
Once discovered, action needs to be taken to remove the potential vulnerability from your solution.
185
+
186
+
The easiest case is when a package you reference directly has the known vulnerability.
187
+
In this situation, update the package version to one that fixes the vulnerability.
188
+
189
+
Package vulnerabilities may be reported in both direct and transitive package references.
190
+
The action you take to resolve may be different because of that.
186
191
187
192
### Security vulnerabilities found with updates
188
193
@@ -195,13 +200,60 @@ If security vulnerabilities are found and updates are available for the package,
195
200
196
201
#### Transitive Packages
197
202
198
-
If a known vulnerability exists in a top-level package's transitive dependencies, you have these options:
203
+
Often a vulnerability will be in a transitive dependency.
204
+
Our recommendation is to prefer updates to packages “closest” to your direct references.
205
+
Though, there's nothing wrong with just upgrading the package with known vulnerability either.
206
+
207
+
For example, say your project references package A.
208
+
Package A has a dependency on package B, which in turn has a dependency on package C.
209
+
In this example, we'll consider that package C version 1.0.0 has a known vulnerability, fixed in version 2.0.0.
210
+
Our recommendation is to first try upgrading package A.
211
+
If that doesn't resolve the audit warning, then try upgrading package B.
212
+
If that doesn't resolve the audit warning, then upgrade C directly.
213
+
To aid with this, you'll [need to find the transitive package path](#finding-the-transitive-package-path).
214
+
215
+
In summary, if a known vulnerability exists in a top-level package's transitive dependencies, you have these options:
199
216
217
+
- Check if the top-level package contains an update that does not have a transitive vulnerability and update that instead.
218
+
- Update the closest package to your direct references that does not reference a vulnerability.
200
219
- Add the fixed package version as a direct package reference. **Note:** Be sure to remove this reference when a new package version update becomes available and be sure to maintain the defined attributes for the expected behavior.
201
220
- Use [Central Package Management with the transitive pinning functionality](../consume-packages/Central-Package-Management.md#transitive-pinning).
221
+
Note that if you pack your project into your own package to share with others, [CPM with transitive pinning will cause packages to become dependencies](../consume-packages/Central-Package-Management.md#transitive-pinning-and-pack), even if your project doesn't directly call APIs on that package.
202
222
- [Suppress the advisory](#excluding-advisories) until it can be addressed.
203
223
- File an issue in the top-level package's tracker to request an update.
204
224
225
+
##### Finding the transitive package path
226
+
227
+
There are several ways to find the package path.
228
+
Which method you prefer depends on what tools you normally use during your development.
229
+
230
+
###### dotnet nuget why
231
+
232
+
On the command line, you can use the [`dotnet nuget why` command](/dotnet/core/tools/dotnet-nuget-why) to understand why transitive packages are being included in your project's package graph.
SDK style projects also provide the full package graph under the project's Dependency node.
239
+
It's also searchable!
240
+
Expand search options and enable “search external files”.
241
+
242
+

243
+
244
+
Search the package name, and it will show you all instances under each project's Dependencies node.
245
+
246
+

247
+
248
+
###### Visual Studio NuGet Package Manager UI
249
+
250
+
When you look at the Installed tab in Visual Studio's package manager UI, when the project uses PackageReference for package management, it will show both direct and transitive packages.
251
+
Currently, this only happens when you manage packages for a project, not for the solution.
252
+
253
+
If you mouse hover over a package in the package list, the tooltip will include the name of one direct package that has caused that transitive package to be included in the project.
254
+
255
+

256
+
205
257
### Use Copilot to update packages
206
258
NuGet has released a Model Context Protocol (MCP) server that has the ability to update packages in your project to versions that resolve known vulnerabilities.
207
259
See [Fixing package vulnerabilities](NuGet-MCP-Server.md#fixing-package-vulnerabilities) for more information.
Copy file name to clipboardExpand all lines: docs/reference/errors-and-warnings/NU1901-NU1904.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ For more information, see [the documentation on auditing packages](../../concept
33
33
34
34
### Solution
35
35
36
-
We have [a blog post](https://devblogs.microsoft.com/nuget/nugetaudit-2-0-elevating-security-and-trust-in-package-management/) with more discussion about our recommended actions when your project uses a package with a known vulnerability, and tools that can help.
36
+
We have [documentation on upgrading vulnerable packages](../../concepts/Auditing-Packages.md#actions-when-packages-with-known-vulnerabilities-are-reported) that goes in more detail about our recommended actions when your project uses a package with a known vulnerability, and tools that can help.
37
37
38
38
Upgrading to a newer version of the package is likely to resolve the warning.
39
39
If your project does not reference the package directly (it's a transitive package), [`dotnet nuget why`](/dotnet/core/tools/dotnet-nuget-why) can be used to understand which package caused it to be included in your project.
0 commit comments