Marshalling to SYSTEM - An analysis of CVE-2018-0824
A COM deserialization flaw in Microsoft Windows allowed an attacker to craft a malicious serialized object that, when unmarshalled, could execute arbitrary code with SYSTEM privileges. The vulnerability was in the CMarshalInterceptor::UnmarshalInterface method, which failed to properly validate input from an IStream.
In May 2018 Microsoft patched an interesting vulnerability (CVE-2018-0824) which was reported by Nicolas Joly of Microsoft's MSRC:
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 CMarshalInterceptor::UnmarshalInterface method read and trusted data from an IStream without proper validation, allowing an attacker to specify a malicious class to be instantiated and executed.
Impact
An attacker could achieve remote code execution, and in the demonstrated privilege escalation scenario, execute code as SYSTEM.
What the attacker needed
Attacker can supply a crafted file or script; victim opens the file or visits a malicious website; target COM server allows custom marshalling
The fix
The patch adds a check of a flag from thread-local storage; if not set, UnmarshalInterface exits early without reading from the stream.
How it was found
- Create a fake COM object implementing IStorage and IMarshal interfaces.
- In IMarshal::GetUnmarshalClass, return the GUID of the QC Marshal Interceptor Class.
- In IMarshal::MarshalInterface, write bytes to the IStream to satisfy conditions in CMarshalInterceptor::UnmarshalInterface.
- Compose a Script Moniker using a File Moniker and a New Moniker to bypass restrictions.
- Place a malicious SCT file on disk that runs notepad.
- Call CoGetInstanceFromIStorage to activate the target COM server and trigger deserialization.
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 way for Windows programs to talk to each other. When one program sends an object to another, it serializes it (turns it into data) and the receiver deserializes it (rebuilds the object). This bug meant that a malicious serialized object could trick the receiver into running harmful code with high privileges.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.