Memcached Server SASL Autentication Remote Code Execution Vulnerability
An integer overflow in the SASL authentication handling of the Memcached binary protocol allows a crafted packet to cause a heap buffer overflow. An attacker could potentially achieve remote code execution.
Originally disclosed on Cisco Talos
An integer overflow in processbinsaslauth function which is responsible for authentication commands of Memcached binary protocol can be abused to cause heap overflow and lead to remote code execution.
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 report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely, the code subtracts a 16-bit key length from a 32-bit body length without checking that the body length is at least the key length, causing an integer underflow that results in a small or negative value used for memory allocation.
Impact
A remote attacker could cause a heap buffer overflow, potentially leading to remote code execution, though the overflow may not cause an immediate crash.
What the attacker needed
SASL authentication enabled; network access to Memcached
The fix
The vendor patched the vulnerability, likely by adding a check to ensure the body length is not less than the key length before computing the value length.
How it was found
- Enable SASL authentication when compiling and running Memcached.
- Craft a binary protocol packet with the SASL Auth opcode, a key length of 32, and a body length of 1.
- Send the packet to the Memcached server.
- Observe the heap overflow (e.g., under valgrind) when the server processes the authentication command.
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 report has not been written yet. The Original tab links to the source.
Memcached is a caching system used by many websites. A flaw in how it handles a special authentication command lets an attacker send a malformed request that overflows a memory buffer, which could let them run their own code on the server.
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.