-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dotnet publish -r win10-x64 restores vulnerable package #12240
Comments
Issue is missing Type label, remember to add a Type label |
@mattiaskagstrom Could you please take a look at https://learn.microsoft.com/en-us/nuget/consume-packages/Central-Package-Management#transitive-pinning? You can set non-vulnerable versions to avoid downloading the vulnerable version. Let me know if works for you. |
Issue is missing Type label, remember to add a Type label |
@erdembayar I'm not working on the project that experienced the issue, but if you want it tested I can try to make that happen next week. |
What is your ask from the tooling in this case? I understand the motivation with the vulnerable packages, but the source should not be returning a 400. |
@nkolev92 @zivkan I used below csproj for repro, I removed
|
@erdembayar Runtime dependencies have evolved over the years. They used to be provided by a It's possible that the project in question has a graph pulls those dependencies in. |
My bad, just corrected it. End result is still same runtime dependency is resolved to vulnerable one. |
Yep, that's expect, as the runtime.any.System.Runtime is not a standard dependency. It appears to be brought in by Microsoft.NETCore.Targets. To my knowledge, this is not how runtime assets are provided in .NET Core App 3.1 and later. It is a PackageReference that brings in that package, which itself requests runtime dependencies. The guidance from the SDK team normally is to specify: <PackageReference Include="Microsoft.NETCore.Targets" Version="5.0.0" ExcludeAssets="all" PrivateAssets="all" /> |
@mattiaskagstrom Fyi @jeffkl |
@erdembayar that's not going to work. Have a look at the explanation of NuGet's graph resolution algorithm, particularly the part about Direct Dependency Wins. NuGet first resolves the entire graph using versions specified as package dependencies, and only once the full graph is evaluated, then it resolves which version to use, for example direct dependencies. That first part of the process, evaluating the entire graph using the dependency versions, is still going to download the vulnerable version. I'm not 100% sure, but I think the implementation of CPVM is that pinned transitive packages get represented as direct dependencies in the (internal) graph, but it still needs to see the unpinned version to know that the pinned version needs to be added as a direct dependency. Lock files (packages.lock.json) partially resolve the issue. When a lock file is used in a restore, it doesn't check dependency versions, it only uses the lock file versions. However, when anything requires the lock file to be updated (package added, removed, or a version changed, or @mattiaskagstrom In case you didn't follow my explanation above, unfortunately the way your organization has implemented blocking packages with known vulnerabilities is incompatible with the way that NuGet's PackageReference works. A proxy that blocks nupkg downloads via HTTP 400 responses makes Nuget think the server is broken, but it doesn't prevent the client from attempting to download that version. A different approach that would cause fewer problems would be to use a server that does not upstream to nuget.org, instead republish packages needed to your own private feed. When a known vulnerability is discovered, delete that package version from your private feed, so that Otherwise, any package that has a dependency on a vulnerable package needs to be updated to a new version that does not depend on a vulnerable package version, and that needs to happen all the way up the package chain. That's the only way to get NuGet's "first pass" graph evaluation to avoid packages with known vulnerabilities. |
It's not 100% correct. There are situations in which a transitive dependency will be pruned and not even downloaded, described within the same rule. I think your point is the same as what I mentioned in #12240 (comment).
Probably a typo, as NU1603 will be raised instead, https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu1603. |
The problem is that |
This issue has been automatically marked as stale because we have not received a response in 14 days. It will be closed if no further activity occurs within another 14 days of this comment. |
Keep open. |
@teo-tsirpanis I'm not sure I see the action for NuGet here. |
Hmm, true. OK, feel free to close. |
Closing as we don't think there's a NuGet action needed here. |
@mattiaskagstrom version 5.1.0 of |
Issue copied from: dotnet/sdk#29028
Describe the bug
My organization blocks downloads of packages with known vulnerabilities.
The application is buildable and publishable, but as soon as you add -r win10-x64 it tries to restore runtime.win7.System.Private.Uri/4.3.0.
The package is blocked due to: dotnet/announcements#112
Running sdk 6.0.x on the build agents, and 7.0.0 locally
To Reproduce
The app has this csproj:
Exceptions (if any)
Failed to download package 'runtime.win7.System.Private.Uri.4.3.0'
Further technical details
dotnet --info
.NET SDK:
Version: 7.0.100
Commit: e12b7af219
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19042
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.100\
Host:
Version: 7.0.0
Architecture: x64
Commit: d099f075e4
.NET SDKs installed:
5.0.102 [C:\Program Files\dotnet\sdk]
5.0.201 [C:\Program Files\dotnet\sdk]
5.0.202 [C:\Program Files\dotnet\sdk]
7.0.100 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.22 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
The text was updated successfully, but these errors were encountered: