Exploiting .NET Managed DCOM
The .NET runtime's IManagedObject interface lets a COM client ask a .NET COM server to serialise an object with BinaryFormatter, and the client then deserialises the returned buffer. An attacker who controls a DCOM server can therefore force a .NET client, such as PowerShell's WMI cmdlets, to deserialise attacker-chosen data, leading to code execution in the client process.
googleprojectzero.blogspot.com
Published on googleprojectzero.blogspot.com
One of the more interesting classes of security vulnerabilities are those affecting interoperability technology. This is because these vulnerabilities typically affect any application using the technology, regardless of what the application actually does.
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 runtime's automatic unwrapping of COM objects through IManagedObject::GetSerializedBuffer, which deserialises attacker-supplied data with BinaryFormatter without any trust check.
Impact
An attacker who controls a DCOM server could run code in the process of any .NET client that connects to it, including PowerShell WMI cmdlets, though the text notes firewall rules or login restrictions may block the simpler delegate-based route.
What the attacker needed
Attacker controls a DCOM server; victim .NET client connects to it; network path to the client allowed
The fix
Microsoft did not change the serialisation behaviour; it rewrote the affected broker in native code and warned developers, so the underlying API remains unsafe.
How it was found
- Set up a fake WMI server by changing the registration of the winmgmt service to point at a custom implementation.
- Register a COM class with the expected CLSID so the COM activator starts the fake service for any client.
- Implement the IWbemServices object returned from the login call so it returns a serialised stream naming an unknown assembly.
- Run a PowerShell WMI command from the client against the fake server.
- Observe with Process Monitor that the client process tries to load the named assembly, proving deserialisation happened.
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.
COM is a Microsoft technology that lets programs call each other's objects, and DCOM is the same thing across a network. When a .NET program talks to such an object, the runtime tries to be clever and asks the other side to send back a serialised copy of the object, which it then rebuilds. Rebuilding data from an untrusted source is dangerous because the data can describe objects that run code when they are rebuilt.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.