Skip to content
Memory corruption Write-up Advanced

Further hardening glibc malloc() against single byte overflows

A single-byte overflow in glibc malloc() could be used to defeat ASLR and achieve code execution in a 64-bit process. The author describes a patch that validates length linkage between heap chunks to prevent this technique.

Chris Evans Follow

Published on scarybeastsecurity.blogspot.com

Back in 2014, while at Project Zero, I exploited a buffer overflow of a single NUL byte in glibc. Tavis Ormandy had found the interesting glibc vulnerability but there was skepticism in the Linux community that this was exploitable.

Chris Evans, on scarybeastsecurity.blogspot.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 the lack of validation of length linkage between heap chunks allowed an attacker to corrupt a chunk's size field with a single byte and create aliased chunks, defeating ASLR.

What the attacker needed

A single-byte overflow primitive; glibc malloc(); 64-bit process

The fix

The fix validates length linkage when unlinking chunks, so that a corrupted size field will not match the prev_size stored at the end of the chunk.

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.

This is about a tiny mistake in how a program's memory manager (glibc malloc) handles memory. An attacker who can write just one byte past the end of a buffer could trick the memory manager into revealing where things are in memory, which helps them run their own code. The fix adds a check to make sure the memory manager's internal records are consistent.

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 Chris Evans

View all

11 more disclosed reports, best first.

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.