My RCE PoC walkthrough for (CVE-2021–21974) VMware ESXi OpenSLP heap-overflow vulnerability
A heap overflow in VMware ESXi's OpenSLP service, triggered by a directory agent advertisement message with a long scopes length, allows an attacker to overwrite adjacent heap objects. The author developed a proof-of-concept that achieves remote code execution by using the overflow to build arbitrary read and write primitives and overwrite __free_hook with system.
straightblast.medium.com
Published on straightblast.medium.com
During a recent engagement, I discovered a machine that is running VMware ESXi 6.7.0. Upon inspecting any known vulnerabilities associated with this version of the software, I identified it may be vulnerable to ESXi OpenSLP heap-overflow (CVE-2021–21974).
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 URL length calculation in SLPParseSrvURL adds a fixed offset but the subsequent copy uses a length derived from a strstr search that can run past the URL into the scopes field when the scopes length lacks a null byte, causing a heap overflow.
Impact
An attacker on the local network could achieve remote code execution as the slpd service, but the exploit requires precise heap grooming and works reliably only against a specific ESXi build.
What the attacker needed
Network access to ESXi slpd service; vulnerable ESXi version (6.7.0 build-14320388); ability to send crafted SLP messages
How it was found
- Set up a vulnerable VMware ESXi 6.7.0 trial instance and enable SSH.
- Attach gdbserver to the slpd process and connect from a local gdb client via SSH port forwarding.
- Send a directory agent advertisement message with a scopes length above 256 to trigger the heap overflow.
- Use heap grooming with service requests, service registrations, and attribute requests to place objects and extend free chunks.
- Overwrite the position pointers of a send-buffer to create an arbitrary read primitive and leak heap and libc addresses.
- Overwrite the position pointers of a recv-buffer to create an arbitrary write primitive, then overwrite __free_hook with a stack pivot gadget and system address to execute shell commands.
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.
A heap overflow is when a program writes more data into a memory area than it was supposed to, spilling into neighbouring memory. Here, a network service that helps devices find each other on a local network mishandles a length field, so an attacker can send a crafted message that overwrites nearby data structures. The author then uses this to trick the service into reading and writing arbitrary memory, eventually running their own commands.
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.