Skip to content
Memory corruption Advisory Advanced CVE-2016-8704

Memcached Server Append/Prepend Remote Code Execution Vulnerability

An integer overflow in the binary protocol's append/prepend command handling allows an attacker to cause a heap buffer overflow, potentially leading to remote code execution. The vulnerability can be triggered by sending a crafted packet with a body length smaller than the key length.

Aleksandar Nikolic Follow

Originally disclosed on Cisco Talos

Critical 9.8 View original

An integer overflow in the processbinappendprepend function which is responsible for processing multiple commands of Memcached binary protocol can be abused to cause heap overflow and lead to remote code execution.

Aleksandar Nikolic, on Cisco Talos

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 an integer overflow when calculating the value length (bodylen minus keylen) because both are attacker-controlled and keylen can exceed bodylen, leading to a negative or small value used in memory allocation.

Impact

The heap overflow can be triggered multiple times and may be abused to modify internal slab metadata, potentially leading to information leaks and remote code execution.

What the attacker needed

Network access to Memcached binary port

The fix

The vulnerability was fixed by the vendor on 2016-10-12.

How it was found

  1. Send a binary protocol packet with the append or prepend opcode, a key length larger than the body length, and a body of data.
  2. The server calculates a negative value length and allocates too small a buffer.
  3. The server copies the key into the undersized buffer, causing a heap overflow.

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 to speed up websites. A flaw in how it handles certain commands lets an attacker send a specially crafted request that causes the server to write data beyond the memory it allocated, which can crash the server or allow the attacker to run their own code.

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 Aleksandar Nikolic

View all

147 more disclosed reports, best first.

More from Cisco Talos

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.