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.
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”.
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
- Authenticate to the Autodiscover endpoint using Basic or NTLM authentication.
- Send a request that exploits the path confusion to reach the Exchange PowerShell backend.
- Craft a PowerShell Remoting XML payload specifying an object of type System.ServiceProcess.ServiceController with a TargetTypeForDeserialization property.
- Set the TargetTypeForDeserialization property to a serialized System.Exception containing a UnitySerializationHolder for XamlReader.
- Include a string payload containing a XAML gadget in the <S> tag.
- 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.