wpf icon indicating copy to clipboard operation
wpf copied to clipboard

Microsoft Security Advisory CVE-2022-41089: .NET Remote Code Execution Vulnerability

Open dcwhittaker opened this issue 3 years ago • 57 comments

Microsoft Security Advisory CVE-2022-41089: .NET Remote Code Execution Vulnerability

Executive summary

Microsoft is releasing this security advisory to provide information about a vulnerability in .NET Core 3.1, .NET 6.0., and .NET 7.0. This advisory also provides guidance on what developers can do to update their applications to remove this vulnerability.

A remote code execution vulnerability exists in .NET Core 3.1, .NET 6.0, and .NET 7.0, where a malicious actor could cause a user to run arbitrary code as a result of parsing maliciously crafted xps files.

Announcement

Announcement for this issue can be found at https://github.com/dotnet/announcements/issues/242

Mitigation factors

Microsoft has not identified any mitigating factors for this vulnerability.

Affected software

  • Any .NET 7.0 WinForms or WPF application running on .NET 7.0.0 or earlier.
  • Any .NET 6.0 WinForms or WPF application running on .NET 6.0.11 or earlier.
  • Any .NET Core 3.1 WinForms or WPF application running on .NET 3.1.31 or earlier.

If the application does not utilize WinForms or WPF, it is not affected by this vulnerability.

Applications targeting Mac, Linux, Android, iOS, and other non-Windows platforms are not affected by this vulnerability.

If your application uses the following package versions, ensure you update to the latest version of .NET.

.NET Core 3.1

Package name Affected version Patched version
Microsoft.WindowsDesktop.App.Runtime.win-x64 >= 3.1.0, <= 3.1.31 3.1.32
Microsoft.WindowsDesktop.App.Runtime.win-x86 >= 3.1.0, <= 3.1.31 3.1.32

.NET 6

Package name Affected version Patched version
Microsoft.WindowsDesktop.App.Runtime.win-arm64 >= 6.0.0, <= 6.0.11 6.0.12
Microsoft.WindowsDesktop.App.Runtime.win-x64 >= 6.0.0, <= 6.0.11 6.0.12
Microsoft.WindowsDesktop.App.Runtime.win-x86 >= 6.0.0, <= 6.0.11 6.0.12

.NET 7

Package name Affected version Patched version
Microsoft.WindowsDesktop.App.Runtime.win-arm64 >= 7.0.0, <= 7.0.0 7.0.1
Microsoft.WindowsDesktop.App.Runtime.win-x64 >= 7.0.0, <= 7.0.0 7.0.1
Microsoft.WindowsDesktop.App.Runtime.win-x86 >= 7.0.0, <= 7.0.0 7.0.1

Advisory FAQ

How do I know if I am affected?

If you have a runtime or SDK with a version listed, or an affected package listed in affected software, you're exposed to the vulnerability.

How do I fix the issue?

  • To fix the issue please install the latest version of .NET 7.0, .NET 6.0 or .NET Core 3.1. If you have installed one or more .NET SDKs through Visual Studio, Visual Studio will prompt you to update Visual Studio, which will also update your .NET SDKs.
  • If you have .NET Core 3.1 or greater installed, you can list the versions you have installed by running the dotnet --info command. You will see output like the following;
  • If you are using one of the affected packages, please update to the patched version listed above.
.NET Core SDK (reflecting any global.json):

 Version:   6.0.300
 Commit:    8473146e7d

Runtime Environment:

 OS Name:     Windows
 OS Version:  10.0.18363
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.300\

Host (useful for support):

  Version: 6.0.5
  Commit:  8473146e7d

.NET Core SDKs installed:

  6.0.300 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:

  Microsoft.AspNetCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download
  • If you're using .NET 7.0, you should download and install Runtime 7.0.1 or SDK 7.0.101 (for Visual Studio 2022 v17.4) from https://dotnet.microsoft.com/download/dotnet-core/7.0.
  • If you're using .NET 6.0, you should download and install Runtime 6.0.12 or SDK 6.0.112 (for Visual Studio 2022 v17.1) from https://dotnet.microsoft.com/download/dotnet-core/6.0.
  • If you're using .NET Core 3.1, you should download and install Runtime 3.1.32 (for Visual Studio 2019 v16.9) from https://dotnet.microsoft.com/download/dotnet-core/3.1.

.NET 7.0, .NET 6.0 and .NET Core 3.1 updates are also available from Microsoft Update. To access this either type "Check for updates" in your Windows search, or open Settings, choose Update & Security and then click Check for Updates.

Once you have installed the updated runtime or SDK, restart your apps for the update to take effect.

Additionally, if you've deployed self-contained applications targeting any of the impacted versions, these applications are also vulnerable and must be recompiled and redeployed.

Other Information

Acknowledgements

Eleftherios Panos with Nettitude Nick Landers with NetSPI

Reporting Security Issues

If you have found a potential security issue in .NET 7.0, .NET 6.0 or .NET Core 3.1, please email details to [email protected]. Reports may qualify for the Microsoft .NET Core & .NET 5 Bounty. Details of the Microsoft .NET Bounty Program including terms and conditions are at https://aka.ms/corebounty.

Support

You can ask questions about this issue on GitHub in the .NET GitHub organization. The main repos are located at https://github.com/dotnet/runtime and https://github.com/dotnet/wpf/. The Announcements repo (https://github.com/dotnet/Announcements) will contain this bulletin as an issue and will include a link to a discussion issue. You can ask questions in the linked 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

CVE-2022-41089

Revisions

V1.0 (December 13, 2022): Advisory published.

Version 1.0

Last Updated 2022-12-13

dcwhittaker avatar Dec 13 '22 18:12 dcwhittaker

I'd like to merge the fix into my fork, but https://github.com/dotnet/wpf/commits/release/6.0 doesn't appear to be updated with the latest code, and https://github.com/dotnet/wpf/tree/v6.0.12 "may belong to a fork outside of the repository."

Will the fix for WPF 6.0 be pushed to a branch on dotnet/wpf soon?

bgrainger avatar Dec 13 '22 20:12 bgrainger

@bgrainger Apologies about that. I spoke with some of our servicing team and the ETA for getting the commits pushed to the existing release/* branches is after the holidays. There's a backlog the normal crew is working through and I don't want to do anything to the branches manually that might interfere with their work.

However, I plan on submitting a PR with the fix to this repo's main branch tomorrow once I'm back in the office. It's identical to the fix that was checked in to the downlevel servicing branches, so it should be good to cherry-pick. Keep an eye out for that PR.

Hope that helps!

GrabYourPitchforks avatar Dec 13 '22 23:12 GrabYourPitchforks

Are .NET Framework applications affected by this?

skrysm avatar Dec 14 '22 11:12 skrysm

Are .NET Framework applications affected by this?

@skrysmanski Yes, a patch is available for .NET Framework 3.5 and 4.x applications. See https://devblogs.microsoft.com/dotnet/dotnet-framework-december-2022-security-and-quality-rollup-updates/ for more information.

GrabYourPitchforks avatar Dec 14 '22 18:12 GrabYourPitchforks

I tried to read an XPS document with images and display it on the screen, it will not be displayed images after windows update.

WPF native controls are not visible even in the DocumentViewer.

I tried the method described at https://devblogs.microsoft.com/dotnet/dotnet-framework-december-2022-security-and-quality-rollup-updates/ but it was the same.

please help me.

akon47 avatar Dec 15 '22 04:12 akon47

@akon47 Could you please share the xps file with us? Also please confirm if you have run the powershell script mentioned in the KB article successfully. Thanks.

singhashish-wpf avatar Dec 15 '22 04:12 singhashish-wpf

@akon47 Could you please share the xps file with us? Also please confirm if you have run the powershell script mentioned in the KB article successfully. Thanks.

test_xps.zip

image

image

It looks fine in the Windows default viewer.

akon47 avatar Dec 15 '22 04:12 akon47

@akon47 Could you please share the xps file with us? Also please confirm if you have run the powershell script mentioned in the KB article successfully. Thanks.

more xps sample.

test2_xps.zip

image

akon47 avatar Dec 15 '22 10:12 akon47

The problem is for apps built in .NET Framework, and .Net Core 3.1 on Windows 10 with kb5021088 and Windows 11 with KB5020880 and script KB5022083 installed.

I prepared simple app which generates and displays XpsDocument to reproduce this. There are 3 projects and xps file. Only project with target framework .NET 5 works fine another ones displays white page. WpfBug7357.zip Is there any option to print and display XpsDocument with image from .NET Framework app?

martindsa avatar Dec 15 '22 20:12 martindsa

@akon47 @martindsa The KB article was just updated with more information. The KB article provides a primary workaround which should work for most people, plus a secondary workaround which can be used in emergencies. (See the warning text which accompanies the secondary workaround.) The KB article should unblock your scenarios.

GrabYourPitchforks avatar Dec 16 '22 03:12 GrabYourPitchforks

@akon47 @martindsa The KB article was just updated with more information. The KB article provides a primary workaround which should work for most people, plus a secondary workaround which can be used in emergencies. (See the warning text which accompanies the secondary workaround.) The KB article should unblock your scenarios.

After that registry setting, the XPS document looks fine in WPF app.

Any update planned to make it work normally without registry setting?

akon47 avatar Dec 16 '22 03:12 akon47

@akon47 Yes, an update is being planned for that. The timelines, however, are still under discussion.

singhashish-wpf avatar Dec 16 '22 05:12 singhashish-wpf

Have you decided anything about an update, when it will be available? Disabling security update on clients operating systems is not a long term solution.

martindsa avatar Jan 04 '23 21:01 martindsa

This issue (not seeing images in an XPS document) is also affecting us. The recommended workaround in KB5022083 does not help us and we don't really want to do the alternate workaround (or rather ... suggest it to our customers) since it simply rolls back the security fix.

Our customers are currently down and unable to see images in their reports. We are contemplating a reworking of our reporting engine to avoid the issue ... so it would be really nice to know the timeline of your fix. That is, is it imminent? Or is it going to be in a few weeks? More than that?

Thank you!

cplotts avatar Jan 04 '23 22:01 cplotts

Add me to the list of people interested in how this can be fixed securely. We have lots of WPF applications which generate reports using images inside FlowDocument and XPS and this is going to be a huge issue pretty soon. Please give us a clue as to how "The Windows XPS Viewer application provided within the Windows operating system is not affected by this issue." was implemented ? Is the problem mainly with BlockUIContainer ? How else can images be embedded into FlowDocument ? Should we be creating FixedDocument or will that get the security "fix" in the next release ? Thank you in advance

ajt2018 avatar Jan 05 '23 10:01 ajt2018

The Windows XPS Viewer application provided within the Windows operating system is not affected by this issue

The reason XPS Viewer application provided within the Windows operating system is not affected by this issue is because it does not rely on .NET API to process XPS documents.

We're working on restoring the images rendering within XPS that were blocked by the security update so that applications that are using images don't need to make any changes.

We'll keep this thread posted.

pchaurasia14 avatar Jan 06 '23 17:01 pchaurasia14

We're working on restoring the images rendering within XPS that were blocked by the security update so that applications that are using images don't need to make any changes.

Do you have any idea on a timeline for that fix? Or can you post here when you have an ETA?

cplotts avatar Jan 06 '23 17:01 cplotts

Sure, we'll keep this thread up to date as soon as we have more information.

pchaurasia14 avatar Jan 06 '23 17:01 pchaurasia14

Hello, our comany has big problem as well since mentioned update has been updated. Please be aware that a lot of our product use xps to generate reports/printouts and we hope that fix will come soon.

rysik007 avatar Jan 09 '23 08:01 rysik007

We also have problems with FlowDocument/FixedDocument not showing images anymore. I can confirm that it does also happen in .NET 4.8 Framework, not only in .NET Core. Workaround KB5022083 did not solve the problem. As a temporary workaround, we changed/rewrote our reporting system "quickly" to process OpenXml-Documents (Word) instead of XAML, so that our customer can work again...

There is at least our and another stackoverflow thread about this problem:

  • https://stackoverflow.com/questions/74833484/flowdocument-xps-with-windows-update-kb5020880-cve-2022-41089
  • https://stackoverflow.com/questions/74879585/wpf-xps-document-doesnt-display-images-anymore/74931766

Microsoft should solve the problem of "Code Execution Vulnerability" on it's root and not just stop processing images as a solution. Any timeline for a fix would be great.

bluebat-swiss avatar Jan 11 '23 16:01 bluebat-swiss