Microsoft Security Advisory CVE-2018-8356: .NET Core Security Feature Bypass Vulnerability #3009
Description
Microsoft Security Advisory CVE-2018-8356: .NET Core Security Feature Bypass Vulnerability
Executive summary
Microsoft is releasing this security advisory to provide information about a vulnerability in .NET Core. This advisory also provides guidance on what developers can do to update their applications to remove this vulnerability.
Microsoft is aware of a security feature bypass vulnerability that exists when .NET Core does not correctly validate certificates. An attacker who successfully exploited this vulnerability could present an expired certificate when challenged.
The update addresses the vulnerability by correcting how .NET Core applications handle certificate validation.
Announcement
The original announcement for this issue can be found at dotnet/announcements#73
Mitigation factors
- If an application does not use Windows Communication Foundation you are not affected.
Affected software
Any .NET Core, or ASP.NET Core based application that uses System.Private.ServiceModel with a version of 4.5.1 or earlier.
Package name | Vulnerable versions | Secure versions |
---|---|---|
System.Private.ServiceModel | 4.0.0, 4.1.0, 4.1.1 4.3.0, 4.3.1 4.4.0, 4.4.1, 4.4.2 4.5.0, 4.5.1 |
4.1.3 or later 4.3.3 or later 4.4.4 or later 4.5.3 or later |
System.ServiceModel.Duplex | 4.0.0, 4.0.1, 4.0.2 4.3.0, 4.3.1 4.4.0, 4.4.1, 4.4.2 4.5.0, 4.5.1 |
4.0.4 or later 4.3.3 or later 4.443 or later 4.5.3 or later |
System.ServiceModel.Http | 4.0.0, 4.0.10, 4.1.0, 4.1.1 4.3.0, 4.3.1 4.4.0, 4.4.1, 4.4.2 4.5.0, 4.5.1 |
4.1.3 or later 4.3.3 or later 4.4.4 or later 4.5.3 or later |
System.ServiceModel.NetTcp | 4.0.0, 4.1.0, 4.1.1 4.3.0, 4.3.1 4.4.0, 4.4.1, 4.4.2 4.5.0, 4.5.1 |
4.1.3 or later 4.3.3 or later 4.4.4 or later 4.5.3 or later |
System.ServiceModel.Primitives | 4.0.0, 4.1.0, 4.1.1 4.3.0, 4.3.1 4.4.0, 4.4.1, 4.4.2 4.5.0, 4.5.1 |
4.1.2 or later 4.3.3 or later 4.4.4 or later 4.5.3 or later |
System.ServiceModel.Security | 4.0.0, 4.0.1, 4.0.2 4.3.0, 4.3.1 4.4.0, 4.4.1, 4.4.2 4.5.0, 4.5.1 |
4.0.4 or later 4.3.3 or later 4.4.4 or later 4.5.3 or later |
Advisory FAQ
How do I know if I am affected?
.NET Core projects have two types of dependencies: direct and transitive. You must update your projects using the following instructions to address both types of dependency.
.NET Core Project formats
.NET Core has two different project file formats, depending on what software created the project.
project.json
is the format used in .NET Core 1.0 and Microsoft Visual Studio 2015.csproj
is the format used in .NET Core 1.1, .NET Core 2.0 and Microsoft Visual Studio 2017.
Direct dependencies
Direct dependencies are discoverable by examining your csproj
file or your project.json
file. They can be fixed by editing the project file or using NuGet to update the dependency.
The System.Private.ServiceModel
package is not meant to be directly depended on and will not appear in your direct dependency list.
Transitive dependencies
Transitive dependencies occur when you add a package to your project that in turn relies on another package. For example, if Contoso publishes a package Contoso.Utility
which, in turn, depends on Contoso.Internals
and you add the Contoso.Utility
package to your project now your project has a direct dependency on Contoso.Utility
and, because Contoso.Utility
depends 'Contoso.Internals', your application gains a transitive dependency on the Contoso.Internals
package.
Transitive dependencies are reviewable in three ways, depending on your project format:
- In the Visual Studio Solution Explorer window, which supports searching.
- By examining the
project.assets.json
file contained in the obj directory of your project forcsproj
based projects OR. - By examining the
project.lock.json
file contained in the root directory of your project forproject.json
based projects.
The project.assets.json
and project.lock.json
files are the authoritative list of all packages used by your project, containing both direct and transitive dependencies.
Fixing direct dependencies in a csproj based project / Visual Studio 2017
Open projectname.csproj in your editor. If you're using Visual Studio, right-click the project and choose Edit projectname.csproj from the context menu, where projectname is the name of your project. Look for PackageReference
elements. The following shows an example project file:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.ServiceModel.Http" Version="4.4.0" />
</ItemGroup>
</Project>
The preceding example has a reference to the vulnerable package, as seen by the single PackageReference
element. The name of the package is in the Include
attribute.
The package version number is in the Version
attribute. The previous example shows a single direct dependency on System.ServiceModel.Http
version 4.4.0.
To update the version to the secure package, change the version number to the updated package version as listed on the table previously.
In this example, update System.ServiceModel.Http
to the appropriate fixed package number for your major version. Save the csproj file. The example csproj now looks as follows:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.ServiceModel.Http" Version="4.4.3" />
</ItemGroup>
</Project>
If you're using Visual Studio and you save your updated csproj file, Visual Studio will restore the new package version.
You can see the restore results by opening the Output window (Ctrl+Alt+O) and changing the Show output from drop-down list to Package Manager.
If you're not using Visual Studio, open a command line and change to your project directory. Execute the dotnet restore
command to restore the updated dependencies.
Now recompile your application. If after recompilation you see a Dependency conflict warning, you must update your other direct dependencies to versions that take a dependency on the updated package.
Fixing Direct Dependencies in project.json based project / Visual Studio 2015
Open your project.json
file in your editor. Look for the dependencies section. Below is an example dependencies section:
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
"Microsoft.AspNetCore.Mvc.Core": "1.0.6",
"System.ServiceModel.Http" : "4.0.0"
}
This example has three direct dependencies: Microsoft.NETCore.App
, Microsoft.AspNetCore.Mvc.Core
and System.ServiceModel.Http
.
Microsoft.NetCore.App
is the platform the application targets, you should ignore this. The other packages expose their version to the right of the package name. In our example, our non-platform packages are version 1.0.1.
Review your direct dependencies for any instance of the packages and versions listed above. In the example above, there is a direct dependency on a vulnerable package, System.ServiceModel.Http
version 4.4.0.
To update to the fixed package, change the version number to be the appropriate package for your release. In the example, this would be updating System.ServiceModel.Http
to 4.4.3.
After updating the vulnerable package versions, save your project.json
file.
The dependencies section in our example project.json
would now look as follows:
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
"Microsoft.AspNetCore.Mvc.Core": "1.0.6",
"System.ServiceModel.Http ": "4.4.3"
}
If you are using Visual Studio and save your updated project.json
file, Visual Studio will restore the new package version. You can see the restore results by opening the Output Window (Ctrl+Alt+O) and 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 dependency.
After you have addressed all of your direct dependencies, you must also review your transitive dependencies.
After you've addressed all of your direct dependencies, you must review your transitive dependencies.
Discovering and fixing transitive dependencies
There are two ways to view transitive dependencies. You can either use Visual Studio’s Solution Explorer, or you can review the project.assets.json
file or the the project.lock.json
file.
Using Visual Studio Solution Explorer
To use Solution Explorer, open the project in Visual Studio, and then press Ctrl+; to activate the search in Solution Explorer. Search for the vulnerable package and make a note of the version numbers of any results you find.
For example, searching for Microsoft.AspNetCore.Mvc.Core
in an example project that contains a package that takes a dependency on Microsoft.AspNetCore.Mvc
shows the following results in Visual Studio 2017:
The search results appear as a tree. In the previous results, you can see that a reference to Microsoft.AspNetCore.Mvc.Core
version 1.1.2 is discovered.
Under the Dependencies node is a NuGet node. Under the NuGet node is the list of packages you have directly taken a dependency on and their versions.
In screenshot, the application takes a direct dependency on Microsoft.AspNetCore.Mvc
. Microsoft.AspNetCore.Mvc
in turn has leaf nodes that list its dependencies and their versions.
The Microsoft.AspNetCore.Mvc
package takes a dependency on a version of Microsoft.AspNetCore.Mvc.ApiExplorer
, that in turn takes a dependency on a version of Microsoft.AspNetCore.Mvc.Core
.
Manually reviewing project.assets.json (csproj/VS2017)
Open the project.assets.json file from your project’s obj directory in your editor. We suggest you use an editor that understands JSON and allows you to collapse and expand nodes to review this file.
Visual Studio and Visual Studio Code provide JSON friendly editing.
Search the project.assets.json file for the vulnerable package, using the format packagename/
for each of the package names from the preceding table. If you find the assembly name in your search:
- Examine the line on which they are found, the version number is after the
/
. - Compare to the vulnerable versions table.
For example, a search result that shows System.ServiceModel.Http/4.3.0
is a reference to version 4.3.0 of System.ServiceModel.Http
.
If your project.assets.json file includes references to the vulnerable package, then you need to fix the transitive dependencies.
If you have not found any reference to any vulnerable packages, this means either
- None of your direct dependencies depend on any vulnerable packages, or
- You have already fixed the problem by updating the direct dependencies.
If your transitive dependency review found references to the vulnerable package, you must add a direct dependency to the updated package to your csproj file to override the transitive dependency.
Open projectname.csproj in your editor. If you're using Visual Studio, right-click the project and choose Edit projectname.csproj from the context menu, where projectname is the name of your project.
Look for PackageReference
nodes, for example:
<Project Sdk="Microsoft.NET.Sdk.">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ThirdParty.NotUpdatedYet" Version="2.0.0" />
</ItemGroup>
</Project>
You must add a direct dependency to the updated version of the vulnerable package by adding it to the csproj file.
You do this by adding a new line to the dependencies section, referencing the fixed version.
For example, if your search showed a transitive reference to a vulnerable System.ServiceModel.Http
version, you'd add a reference to the fixed package number.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.ServiceModel.Http" Version="4.3.2" />
<PackageReference Include="ThirdParty.NotUpdatedYet" Version="2.0.0" />
</ItemGroup>
</Project>
After you've added the direct dependency reference, save your csproj file.
If you're using Visual Studio, save your updated csproj file and Visual Studio will restore the new package versions.
You can see the restore results by opening the Output window (Ctrl+Alt+O) and changing the Show output from drop-down list to Package Manager.
If you're not using Visual Studio, open a command line and change to your project directory. Execute the dotnet restore
command to restore the new dependencies.
Manually reviewing project.lock.json (project.json/VS2015)
Open the project.lock.json
file in your editor. We suggest you use an editor that understands json and allows you to collapse and expand nodes to review this file; both Visual Studio and Visual Studio Code provide this functionality.
If you are using Visual Studio the project.lock.json
file is “under” the project.json
file. Click the right pointing triangle, ▷, to the left of the project.json
file to expand the solution tree to expose the project.lock.json
file. The following image shows a project with the project.json
file expanded to show the project.lock.json
file.
Search the project.lock.json
file for the vulnerable packages, using the format packagename/
, using each of the package names from the table above. If you find any vulnerable assembly name in your search examine the line on which they are found, the version number is after the /
and compare to the vulnerable versions table above. For example a search result that shows System.ServiceModel.Http/4.0.1
is a reference to v4.0.1 of System.ServiceModel.Http
. If your project.lock.json
file includes references to any of the package versions shown above then you will need to fix the transitive dependencies.
If you have not found any reference to a vulnerable version of System.ServiceModel.Http
this means none of your direct dependencies depend on any vulnerable packages or you have already fixed the problem by updating the direct dependencies.
If your transitive dependency review found references to any of the vulnerable packages you must add a direct dependency to the updated package to your project.json
file to override the transitive dependency. Open your project.json
and find the dependencies section. For example:
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
"Microsoft.AspNetCore.Mvc": "1.0.0"
}
For each of the vulnerable packages your search returned you must add a direct dependency to the updated version by adding it to the project.json
file. You do this by adding a new line to the dependencies section, referring the fixed version. For example, if your search showed a transitive reference to the vulnerable System.ServiceModel.Http
version 1.0.0 you would add a reference to the appropriate fixed version, 1.0.6. Edit the project.json
file as follows:
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
"System.ServiceModel.Http": "4.1.2",
"Microsoft.AspNetCore.Mvc": "1.0.0"
}
After you have added direct dependencies to the fixed packages, save your project.json
file.
If you are using Visual Studio save your updated project.json
file and Visual Studio will restore the new package versions. You can see the restore results by opening the Output Window (Ctrl+Alt+O) and 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.
Rebuilding your application
Finally you must rebuild your application, test, and redeploy.
Other Information
Reporting Security Issues
If you have found a potential security issue in .NET Core, please email details to secure@microsoft.com. Reports may qualify for the .NET Core Bug Bounty. Details of the .NET Core Bug Bounty including terms and conditions are at https://aka.ms/corebounty.
Support
You can ask questions about this issue on GitHub in the .NET Core or ASP.NET Core organizations. These are located at https://github.com/dotnet/ and https://github.com/aspnet/. The Announcements repo for each product (https://github.com/dotnet/Announcements and https://github.com/aspnet/Announcements) will contain this bulletin as an issue and will include a link to a discussion issue. You can ask questions in the discussion issue.
Disclaimer
The information provided in this advisory is provided "as is" without warranty of any kind. Microsoft disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall Microsoft Corporation or its suppliers be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if Microsoft Corporation or its suppliers have been advised of the possibility of such damages. Some states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation may not apply.
External Links
Revisions
V1.1 (July 23, 2018): Updated package versions, as some assemblies were released unsigned.
V1.0 (July 10, 2018): Advisory published.
Version 1.1
Last Updated 2018-07-23