Skip to content
Memory corruption Write-up Advanced

Remote Deserialization Bug in Microsoft's RDP Client through Smart Card Extension (CVE202138666) Bounty award: $5,000.

The Microsoft RDP client deserialises smart card extension data using the RPC NDR engine without properly validating the input buffer length or the array counts inside the serialised data. An attacker controlling a malicious RDP server could cause out-of-bounds reads and heap corruption in the client, potentially leading to remote code execution.

blog.thalium.re

Published on blog.thalium.re

This is the third installment in my three-part series of articles on fuzzing Microsoft’s RDP client, where I explain a bug I found by fuzzing the smart card extension.

The author, on blog.thalium.re

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 RDP client passes an attacker-controlled buffer length and array counts to the RPC NDR deserialiser, which performs an endianness-conversion pass over the whole buffer without checking that the declared length matches the actual data, causing out-of-bounds reads and heap corruption.

Impact

An attacker-controlled RDP server could cause out-of-bounds reads and heap corruption in the client, which Microsoft assessed as remote code execution with critical severity, although the author did not produce a working exploit.

What the attacker needed

Victim connects to a malicious RDP server; server opens the RDPDR smart card channel

The fix

Microsoft released a security patch for the vulnerability.

How it was found

  1. Set up a malicious RDP server that opens the RDPDR virtual channel and the smart card sub-protocol.
  2. Send a Device Control Request PDU with an IoControlCode that selects a smart card structure and an InputBufferLength larger than the actual input buffer.
  3. Include array count fields inside the serialised data that are larger than the real buffer, so the NDR conversion pass byteswaps DWORDs beyond the buffer.
  4. Observe the client crash in RPCRT4.DLL during NdrSimpleTypeConvert, or later heap corruption crashes in other modules.

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 you connect to a remote desktop server, your computer runs a client program that receives data from that server. This report shows that a malicious server could send specially crafted data that makes the client read past the end of a memory buffer and corrupt its own memory. That could crash the client or, in theory, let the server run code on your machine.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.