How do I know if I am affected? .NET has two different types of dependencies: direct and transitive.
If your .NET Framework or .NET Core project has either a direct or transitive dependency on any of the affected packages listed in the “Affected Software” section, then it may be affected.

Direct Dependencies
Direct dependencies occur when you specifically add a package to your project.

For example, if you add the Microsoft.IdentityModel.Tokens package to your project, then you have taken a direct dependency on Microsoft.IdentityModel.Tokens.
Direct dependencies are discoverable by reviewing your project.json or .proj file.

Transitive Dependencies
Transitive dependencies occur when you add a package to your project that in turn relies on another package.
Transitive dependencies are reviewable in the Microsoft Visual Studio Solution Explorer window, which also supports search, or by reviewing the project.lock.json file contained in the root directory of your project.

This file contains the authoritative list of packages for your project.

How do I fix my affected app?
You will need to fix both direct dependencies and review and fix any transitive dependencies.
Version 5.1.1 of the vulnerable package contains the fixes required to secure your app.

Fixing .NET Framework Project Dependencies
Option 1: Update your Visual Studio project packages using NuGet, recompile your application, and deploy
Open your solution in Visual Studio.
In Solution Explorer, right-click the References node and then click Manage NuGet Packages.
Select the Updates tab.

A list of packages with updates appears in the center pane.
Select the Microsoft.IdentityModel.Tokens package and then click Update.
Compile and deploy your application.
For more information about managing NuGet Packages using the NuGet dialog, see Managing NuGet Packages Using the Dialog.

Option 2: Update your Visual Studio project packages using the Package Manager Console UI, recompile your application, and deploy
Open your solution in Visual Studio.
Click the Tools menu, select Library Package Manager, and then click Package Manager Console.
In the package manager window, enter Update-Package Microsoft.IdentityModel.Tokens.
Compile and deploy your application.
For more information about using the Package Manager Console, see Using the Package Manager Console.

Fixing .NET Core Project Dependencies

.NET Core Project Direct Dependencies
To fix direct dependencies:
Open your project.json file in your editor. Look for the dependencies section.

The following provides an example section:

“dependencies”: {
“Microsoft.IdentityModel.Tokens”: “5.1.0”,
}

In this example, Microsoft.IdentityModel.Tokens is a direct dependency. Update its version to 5.1.1 to download a version of this package that isn’t affected.

After updating the package version, save your project.json file.

The dependencies section in our example project.json file would now appear as follows:

“dependencies”: {
“Microsoft.IdentityModel.Tokens”: “5.1.1”,
}

If you are using Visual Studio and save your updated project.json file, the new version will be restored by Visual Studio. You can see the restore results by opening the Output Window (Ctrl+Alt+O), and then changing the Show output from drop-down list to Package Manager.
If you are not using Visual Studio, open a command line and change to your project directory.

Execute the dotnet restore command to restore your new dependencies.

After you have addressed all of your direct dependencies, you are ready to review your transitive dependencies.

.NET Core Project Transitive Dependencies

Reviewing Transitive Dependencies
There are two ways to view transitive dependencies: Use Visual Studio Solution Explorer, or review your project.lock.json file.

Using Visual Studio Solution Explorer
If you want to use Solution Explorer, open your project in Visual Studio, and then press Ctrl+; to activate the search in Solution Explorer.
Search for the package name Microsoft.IdentityModel.Tokens.
If results are found and the version is 5.1.0, your project takes a transitive dependency on Microsoft.IdentityModel.Tokens.

Fixing .NET Core Project Transitive Dependencies
If you have not found Microsoft.IdentityModel.Tokens, then either none of your dependencies in turn depend on the vulnerable package, or you have already fixed the problem by updating the direct dependencies.
If your transitive dependency review has shown that you use the vulnerable package, then you must add a direct dependency to an updated version of each vulnerable package to your project.json file to override the transitive dependency. Open your project.json file and find the dependencies section.

For example:

“dependencies”: {
“VulnerablePackage”: “1.0.0-*”
}

The results of the transitive package search show that a package your app uses depends on Microsoft.IdentityModel.Tokens version 5.1.0.

To fix this example, you must add a direct dependency by adding it to the project.json file. You can do this by adding a new line to the dependencies section that refers to the fixed version.

Edit the project.json file as follows:

“dependencies”: {
“Microsoft.IdentityModel.Tokens”: “5.1.1”,
“VulnerablePackage”: “1.0.0-*”
}

After adding direct dependencies to the fixed packages, save your project. json file.
If you are using Visual Studio, saving the updated project.json file stores the new versions in Visual Studio.

To see the restore results, open the Output Window (Ctrl+Alt+O) and change the Show output from drop-down list to Package Manager.
If you are not using Visual Studio, open a command line and change to your project directory.

Execute the dotnet restore command to restore your new dependencies.
You may want to check for transitive dependencies again to ensure that you have fixed all of them.

Rebuilding Your App
Finally, rebuild your app, test it as you normally would, and then redeploy it using your favored deployment mechanism.

Leave a Reply