Skip to content
RCE Write-up Advanced

Control Your Types Or Get Pwned: Remote Code Execution In Exchange Powershell Backend

The ProxyShell path confusion (CVE-2021-34473) was not fully fixed, allowing authenticated users to reach the Exchange PowerShell backend. A deserialization flaw in PowerShell Remoting (CVE-2022-41082) lets an attacker control the target type and invoke XamlReader.Parse, leading to remote code execution.

Piotr Bazydło Follow

Published on zerodayinitiative.com

By now you have likely already heard about the in-the-wild exploitation of Exchange Server, chaining CVE-2022-41040 and CVE-2022-41082. It was originally submitted to the ZDI program by the researcher known as “DA-0x43-Dx4-DA-Hx2-Tx2-TP-S-Q from GTSC”.

Piotr Bazydło (@chudyPB), on zerodayinitiative.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the Exchange custom converter SerializationTypeConverter allows deserialization of an arbitrary Type object, which is then used as the target type for conversion, enabling invocation of methods like XamlReader.Parse.

Impact

An authenticated attacker could execute arbitrary code on the Exchange server.

What the attacker needed

Valid credentials for Exchange; legacy authentication enabled on Autodiscover

How it was found

  1. Authenticate to the Autodiscover endpoint using Basic or NTLM authentication.
  2. Send a request that exploits the path confusion to reach the Exchange PowerShell backend.
  3. Craft a PowerShell Remoting XML payload specifying an object of type System.ServiceProcess.ServiceController with a TargetTypeForDeserialization property.
  4. Set the TargetTypeForDeserialization property to a serialized System.Exception containing a UnitySerializationHolder for XamlReader.
  5. Include a string payload containing a XAML gadget in the <S> tag.
  6. The backend deserializes the property, retrieves the XamlReader type, and calls XamlReader.Parse on the string, executing code.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

This report describes two bugs in Microsoft Exchange. The first lets a logged-in user reach a powerful backend service that should be restricted. The second lets that user trick the backend into running their code by abusing how it converts data types.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by Piotr Bazydło

View all

14 more disclosed reports, best first.

More from Checkmk

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.