Skip to content

Compiler dependency NuGet.Packaging 6.14.0 triggers NU1901 vulnerability warning in user builds #39

Closed

Description

Observed

A user upgrading PostSharp Threading from 2025.1.6 to 2026.0.12 (Visual Studio 2022, .NET 8, .NET SDK 8.0.313 on CI) gets a compiler warning on every build:

...\DependencyRestore\8.0.313\net8.0-windows10.0.26100-sdk8.0.313-win-x64--ps2026.0.12.0-ee5c0b5.deps.proj : warning NU1901: Package 'NuGet.Packaging' 6.14.0 has a known low severity vulnerability

Root cause

PostSharp's .NET Core compiler host populates a fallback package directory by generating a synthetic <id>.deps.proj and running dotnet restore on it (BuildTimeDependencyRestorer.CreateDependencyRestoreProject, Core/PostSharp.MSBuild/NetCore/BuildTimeDependencyRestorer.cs). That project lists the compiler's own dependencies, including NuGet.Packaging 6.14.0 (referenced by PostSharp.Compiler.Engine).

On .NET SDK 8.0.3xx and later, NuGet auditing is on by default, so the restore emits NU1901 for that package. The restore runs inside the PostSharpCompile MSBuild task; its stdout is piped through ToolInvocationHelper → Log.LogMessageFromText, which recognizes the canonical file : warning CODE: text line and re-raises it as a real warning (code NU1901) in the user's build. Hence it surfaces as a "Compiler Warning."

Why this deserves fixing

  • The user cannot act on it — the compiler's dependency versions are fixed by the PostSharp version.
  • It is noise in every user build on a current SDK, and projects that treat warnings as errors fail.

Remediation

  1. Bump NuGet.Packaging past the advisory and re-audit the full compiler dependency closure (note NuGet.Frameworks / NuGet.Versioning move in lockstep; keep net8.0 compiler-host compatibility).
  2. Enforce auditing in PostSharp's own build — turn on NuGetAudit (warning or error) for the Engine project, similar to the existing <NuGetAuditLevel>low</NuGetAuditLevel> on Core/PostSharp.Compiler.Platform.NetCore/PostSharp.Compiler.Platform.NetCore.csproj. New advisories then surface in PostSharp CI and get fixed in a point release, instead of first appearing in customer builds.

We intentionally do not hard-disable NuGet auditing in the generated restore project: that would permanently silence every severity (including a future NU1903/NU1904) for every user, hiding a signal they may want even when they can't fix it themselves. The scoped, opt-in alternative is tracked separately in #40.

Workaround for affected users on an older PostSharp + newer SDK

  • Targeted: <MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);NU1901</MSBuildWarningsAsMessages> in Directory.Build.props. Demotes the warning where it is actually re-raised (the main build), only for NU1901.
  • Location-independent: set a NuGetAudit=false environment variable on the build agent. MSBuild reads env vars as global properties and the parent environment flows into the child dotnet restore, so it reaches the generated .deps.proj without needing a file in the temp directory — but it is build-wide (also silences audit of the user's own packages).

🤖 Generated with Claude Code

Activity

  1. gfraiteur commented on Jun 27, 2026

    @gfraiteur
    MemberAuthor

    release/2024.0 is not affected by the concrete symptom.

    I checked the branch:

    • The mechanism is identical — BuildTimeDependencyRestorer still generates the synthetic .deps.proj and runs dotnet restore inside the PostSharpCompile task, so the warning re-raising path is present.
    • However, this branch pins NuGet.Packaging / NuGet.Frameworks / NuGet.Versioning to 6.9.1 (PostSharp.Compiler.Engine.csproj), and 6.9.1 is not in any vulnerable range of the advisory that emits NU1901 (GHSA-g4vj-cjjj-v7hg). Its NuGet.Packaging ranges are 4.9.0-4.9.6, 5.11.0-5.11.6, 6.8.0-6.8.1, 6.11.0-6.11.1, 6.12.0-6.12.4, 6.14.0-6.14.2, 7.0.0-7.0.2, 7.3.0. 6.9.1 sits in the clean gap between the patched 6.8.2 and the vulnerable 6.11.0, so dotnet restore emits no NU1901 and nothing is re-raised into user builds.

    Caveat: the root-cause mechanism is still present, and NuGetAudit is not enforced on the Engine project on 2024.0 (only on PostSharp.Compiler.Platform.NetCore). So if a future advisory ever lands on a package in the compiler restore closure, 2024.0 users would hit the same issue and CI would not catch it first. Backporting remediation #2 (enable NuGetAudit on the Engine project) would close that gap; the dependency bump (remediation #1) is a no-op here for now.

    -- Claude for Gael

  2. gfraiteur commented on Jun 27, 2026

    @gfraiteur
    MemberAuthor

    Released in v2026.0.13.

    -- Claude for Gael

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions