Skip to content
RCE Write-up Advanced

Attacking PowerShell CLIXML Deserialization

PowerShell's CLIXML deserialisation rehydrates certain types, and some of these (breakpoints, CIM instances, registry keys, and third-party module types) trigger side effects such as DNS lookups, NTLM hash leaks, or code execution when untrusted XML is imported. An attacker who can supply a crafted CLIXML file could therefore cause the victim's machine to make requests or run code.

Alexander Andersson Follow

Published on truesec.com

I submitted my research on March 18th, 2024 to Microsoft Security Response Center (MSRC). MSRC closed the case as “fixed” on July 22nd and a month later my research was publicly acknowledged.

Alexander Andersson, on truesec.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 deserialiser rehydrates attacker-chosen types (including breakpoints, CIM instances and third-party module types backed by BinaryFormatter) whose property getters or converters execute code or network calls.

Impact

An attacker could trigger DNS lookups, leak the victim's Net-NTLMv2 hash to a remote host, or achieve remote code execution, though some gadgets require the module to be loaded or all properties to be accessed.

What the attacker needed

Victim deserialises attacker CLIXML; some gadgets need module loaded; some gadgets need all properties read

The fix

Microsoft marked the case fixed, but the author states the attack is still possible and recommends mitigations for IT operations and PowerShell developers.

How it was found

  1. Serialise a Win32_PingStatus object to CLIXML to get a payload template
  2. Edit the Address property in the XML to a domain of your choosing
  3. Deserialise the file with Import-Clixml while watching network traffic
  4. Observe the DNS lookup for the chosen domain being triggered

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.

When a program saves an object to a file it 'serialises' it, and when it reads it back it 'deserialises' it. PowerShell's CLIXML format can rebuild certain objects into live ones, and some of those objects run code or make network calls as soon as their properties are read. So a file that looks like harmless data can make the machine do things when opened.

What is RCE?

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

More from Microsoft

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.