← All posts

What is a CVE, and why should you fix them?

A CVE is a public ID for a known security flaw. This post explains what the ID tells you, how to find CVEs in your NuGet packages and what to fix first.

Every few days, a security flaw in some library gets a CVE number. If your code uses that library, the number now applies to you. This post explains what a CVE is, how to read one, and what to do about the ones in your .NET repositories.

What a CVE is

CVE stands for Common Vulnerabilities and Exposures. It is a public ID for one known security flaw in a piece of software.

The ID looks like CVE-2021-44228: the year it was assigned, then a number. The ID does not describe the flaw. It gives everyone one name for it, so a vendor, a scanner and your team all talk about the same thing.

A CVE record is short: which product and versions are affected, a one-line description, and links to the advisory. Databases such as the National Vulnerability Database and the GitHub Advisory Database add detail, like a severity score and the version that fixes the flaw.

A CVE ID written as CVE-YYYY-NNNNN, with its three parts labelled: the public ID, the year assigned and the number. Below it, three boxes show what a CVE record holds: affected versions, a short description and the fixed version.
What a CVE ID and a CVE record contain.

How to read the severity

Most CVEs carry a CVSS score from 0 to 10. Higher means more severe. NuGet shows it as four labels: low, moderate, high and critical.

The score is a starting point, not the answer. It rates the flaw in general, not in your application. A critical flaw in a function your code never calls can matter less than a moderate one on a path every request takes. The advisory often names the conditions: a framework, an operating system, a feature that must be switched on. Read them.

Why it matters for .NET repositories

Most of the code you ship is not code you wrote. Your project references a few packages. Those packages reference others. These are transitive dependencies. A CVE in a package you never chose can still be in your build.

Once a CVE is public, the flaw is public. Often the fix is too. The open question is how long your repositories keep running the old version.

With one repository, that is a small job. With many similar repositories, it is the same upgrade again in each one, and the repository nobody remembers is the one that stays old.

A chain of four boxes: Your project, Package A, Package B and Package C. You chose Package A. Packages B and C are pulled in for you. A known flaw in Package C reaches your project through the chain.
A flaw in a package you never chose can still reach your build.

How to find CVEs in a .NET project

Since the .NET 8 SDK, NuGet Audit checks your packages on every dotnet restore. It compares them with the GitHub Advisory Database and prints a warning per package:

  • NU1901: low severity
  • NU1902: moderate severity
  • NU1903: high severity
  • NU1904: critical severity

By default, it checks only the packages you reference directly. A project that targets net10.0 or higher checks transitive packages too. You can set NuGetAuditMode to all yourself.

To list the affected packages, run:

dotnet list package --vulnerable --include-transitive

To see why a transitive package is in your project, run:

dotnet nuget why <project> <package>

How to fix one

If you reference the package directly, update it to a version that has the fix. With the .NET 10 SDK, this command updates every vulnerable package to the first version without a known vulnerability:

dotnet package update --vulnerable

If the flaw is in a transitive package, Microsoft's advice is to update the package closest to your direct reference first. If that does not clear the warning, update the next one down, or reference the fixed version directly. Central Package Management can also pin a transitive version for the whole repository.

If no fixed version exists yet, read the advisory for mitigating factors, look for a maintained alternative, or open an issue with the package owner.

What to fix first

A simple order that works:

  1. High and critical flaws in packages that handle input from outside your system.
  2. Any flaw that already has a fixed version.
  3. The rest, in your normal upgrade rhythm.

Then check again. The advisory databases change every day, so a clean result today says nothing about next week. Run the check in your build pipeline, not only on your own machine.

One repository is easy. Many are not.

The commands above work on one project or solution at a time. If your team owns many similar repositories, you run them in each one, and the fix has to be tried and applied in each one.

Smell That Code is built for that part. It sees your repositories as one repository group. An approved version is tried on canary repositories first, and it spreads only after build and tests pass. Security fixes go first.

See how it works