Skip to content
Memory corruption Write-up Advanced

A single byte write opened a root execution exploit

A logic error in c-ares caused a one-byte buffer overflow when a DNS name with an escaped trailing dot was processed, writing a value of 1 outside the allocated heap buffer. By carefully shaping heap allocations through an internal HTTP proxy, an attacker could turn this into memory corruption and ultimately execute code as root on ChromeOS from JavaScript.

daniel.haxx.se

Published on daniel.haxx.se

As one of the maintainers of the c-ares project I’m receiving mails for suspected security problems in c-ares and this was such a one. In this case, the email with said subject came from an individual who had reported a ChromeOS exploit to Google.

The author, on daniel.haxx.se

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 a logic mistake in the length calculation for the DNS query buffer, so an escaped trailing dot made the allocation one byte too small.

Impact

An attacker could execute arbitrary code as root on ChromeOS, but the user had to be tricked into running particular JavaScript.

What the attacker needed

ChromeOS device; victim runs attacker JavaScript; crafted HTTP requests to internal proxy

The fix

The flaw was fixed in c-ares 1.12.0.

How it was found

  1. Send a crafted HTTP request to the ChromeOS internal proxy so it passes a DNS name with an escaped trailing dot to c-ares.
  2. Use a series of requests of various sizes to shape the heap so the c-ares allocation lands in a chosen freed hole.
  3. Trigger the one-byte write of value 1 into the next chunk's header, setting the prev_inuse flag.
  4. Free the c-ares buffer so dlmalloc consolidates it with the following chunk, creating an overlapping free region.
  5. Send another request to allocate that region and place attacker-controlled data into memory still in use.
  6. Trick the user into running JavaScript that leads to code execution as root.

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 program asked for a small block of memory but then wrote one extra byte just past the end of it. That single byte landed in bookkeeping data used by the memory manager, which could later be tricked into handing out overlapping memory, eventually letting an attacker 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.

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.