Microsoft.Data.SqlClient
Affected
- introduced
0, fixed1.1.4(ecosystem)
Fixed versions
1.1.4
Fix
The export has no generic command for this ecosystem.
Advisory
Also known as: CVE-2022-41064
.NET Information Disclosure Vulnerability
Microsoft is releasing this security advisory to provide information about a vulnerability in .NET, .NET Core and .NET Framework's System.Data.SqlClient and Microsoft.Data.SqlClient NuGet Packages.
A vulnerability exists in System.Data.SqlClient and Microsoft.Data.SqlClient libraries where a timeout occurring under high load can cause incorrect data to be returned as the result of an asynchronously executed query.
<a name="mitigation-factors"></a>Mitigation factors
If you are not talking to Microsoft SQL Server from your application you are not affected by this vulnerability.
<a name="how-affected"></a>How do I know if I am affected?
.NET has two types of dependencies: direct and transitive. Direct dependencies are dependencies where you specifically add a package to your project, transitive dependencies occur when you add a package to your project that in turn relies on another package.
For example, the Microsoft.AspNetCore.Mvc package depends on the Microsoft.AspNetCore.Mvc.Core package. When you add a dependency on Microsoft.AspNetCore.Mvc in your project, you're taking a transitive dependency on Microsoft.AspNetCore.Mvc.Core.
Any application that has a direct or transitive dependency on the affected packages listed above are vulnerable.
<a name="how-fix"></a>How do I fix the issue?
Additional Details
.NET and .NET Framework projects have two types of dependencies: direct and transitive. You must update your projects using the following instructions to address both types of dependency.
Additionally, .NET Framework users must also install the November 2022 security patch to be protected.
Direct dependencies
Direct dependencies are discoverable by examining your csproj file. They can be fixed by editing the project file or using nuget command line to update the dependency.
Transitive dependencies
Transitive dependencies occur when you add a package to your project that in turn relies on another package. Transitive dependencies can be discovered by searching the project.assets.json file for each of your projects. This file is produced on each build and is in the obj directory for each project.
The project.assets.json files are the authoritative list of all packages used by your project, containing both direct and transitive dependencies.
Fixing direct dependencies
Direct dependencies are nuget packages that have been specifically added to a project, rather than being pulled in because a nuget package added requires it. They can be seen in the solution explorer in Visual Studio or by opening the csproj for the project and examining the packageReference nodes for the package name, specified by the Include parameter, and its version, specified by the Version parameter.
For example, the following project file has a direct dependency on version 2.1.1 of Microsoft.Data.SqlClient.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.1.1" />
</ItemGroup>
</Project>
Fixing direct dependencies with the nuget command line
Open a command line to the directory holding your project
Run the following command if you are using a version of Microsoft.Data.SqlClient between 2.0.0 and 2.1.1
> dotnet add package Microsoft.Data.SqlClient --version 2.1.2
Run the following command if you are using a version of Microsoft.Data.SqlClient below 1.1.4
> dotnet add package Microsoft.Data.SqlClient --version 1.1.4
Run the following command if you are using a version of System.Data.SqlClient below 4.8.4
> dotnet add package System.Data.SqlClient --version 4.8.5
Fixing direct dependencies by editing the project file
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>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.1.1" />
</ItemGroup>
</Project>
The preceding example has a reference tone of the vulnerable packages 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.
To update the version to the secure package, change the version number to the updated package version as listed in the Affected software section of this document.
In this example, update Microsoft.Data.SqlClient to the appropriate fixed version for your major version. Save the csproj file. The example csproj now looks as follows:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.1.2" />
</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.
Discovering and fixing transitive dependencies
Rebuild your solution and then open the project.assets.json file from in each of 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. Both Visual Studio and Visual Studio Code provide JSON friendly editing.
Search the project.assets.json file for the vulnerable packages above using the format packagename/ for each of the package names from the preceding table. If you find the assembly name in your search:
Medium Basis: The source's own band: MODERATE
0, fixed 1.1.4 (ecosystem)1.1.4
The export has no generic command for this ecosystem.
0, fixed 4.8.5 (ecosystem)4.8.5
The export has no generic command for this ecosystem.
2.0.0, fixed 2.1.2 (ecosystem)2.1.2
The export has no generic command for this ecosystem.
Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0