Skip to content
Memory corruption Write-up Advanced

This Microsoft Windows RCE Vulnerability Gives an Attacker Complete Control

A heap buffer overflow in the Remote Desktop Client's TSMF media decoder, caused by an integer overflow when calculating buffer size, allows an attacker to execute arbitrary code on the victim's machine. This can be exploited by a malicious RDP server or to escape from a Hyper-V virtual machine to the host.

Malcolm Stagg Follow

Published on synack.com

By Malcolm Stagg The Microsoft Windows RCE Vulnerability, or CVE-2021-34535, is a Remote Code Execution (RCE) vulnerability in Remote Desktop Client, found by SRT member Malcolm Stagg earlier this year, and patched by Microsoft in August 2021.

Malcolm Stagg (@malcolmst), on synack.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 an integer overflow in the calculation of buffer size (cbData+63) leading to a heap buffer overflow when copying cbData+36 bytes.

Impact

An attacker could execute arbitrary code on the victim's machine, either by luring them to a malicious RDP server or by escaping from a Hyper-V virtual machine to the host, though exploitation requires bypassing ASLR and the client will crash.

What the attacker needed

Victim connects to malicious RDP server; or attacker runs code in VM with Enhanced Session Mode; ASLR bypass needed for exploitation

The fix

The vulnerability was fixed by Microsoft in August 2021; developers should validate user-controlled data and buffer sizes, check for integer overflow, and verify buffer lengths before copying.

How it was found

  1. Attacker controls a Remote Desktop Server or runs malicious code in a Hyper-V virtual machine.
  2. Victim connects to the malicious server or uses Enhanced Session Mode in Hyper-V.
  3. The server sends a crafted TSMF media packet with a large cbData value.
  4. The client allocates a small buffer due to integer overflow and copies a large amount of data, causing a heap overflow.
  5. Attacker's payload executes before the client crashes, potentially running code on the victim's machine.

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.

The Remote Desktop Client has a bug in how it handles media files sent by a server. When the server sends a very large size value, the program miscalculates the memory needed and writes too much data, letting an attacker run their own code on your computer. This can happen if you connect to a bad server or use a virtual machine with a malicious program.

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.

More by Malcolm Stagg

View all

1 more disclosed report, best first.

More from Microsoft

View all

The newest disclosed reports for this program.

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.