Skip to content
RCE Write-up Advanced

CARPE (DIEM): CVE-2019-0211 Apache Root Privilege Escalation

Apache HTTP server versions 2.4.17 to 2.4.38 have an out-of-bounds array access in the shared memory scoreboard, allowing a low-privilege worker process to set a bucket index that points to attacker-controlled memory. When the server gracefully restarts, the main process calls a function pointer from that memory as root, enabling local privilege escalation.

cfreal.github.io

Published on cfreal.github.io

From version 2.4.17 (Oct 9, 2015) to version 2.4.38 (Apr 1, 2019), Apache HTTP suffers from a local root privilege escalation vulnerability due to an out-of-bounds array access leading to an arbitrary function call. The vulnerability is triggered when Apache gracefully restarts (apache2ctl graceful).

The author, on cfreal.github.io

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

The main process uses a worker-controlled bucket index to access the all_buckets array without bounds checking, leading to an out-of-bounds read and an arbitrary function call.

Impact

A local attacker with the ability to run code as a worker process could escalate to root privileges, but the exploit requires a separate memory corruption vulnerability in a module like PHP and has a success rate of about 80% with default workers, improving with more workers.

What the attacker needed

Local access to run code as a worker process; a separate memory corruption vulnerability (e.g., PHP UAF); Apache configured with mod_prefork, mod_worker, or mod_event; graceful restart triggered (e.g., by logrotate)

The fix

The vulnerability was fixed in Apache HTTP version 2.4.39.

How it was found

  1. Obtain read/write access on a worker process (e.g., via a PHP use-after-free).
  2. Write a fake prefork_child_bucket structure in the shared memory.
  3. Make all_buckets[bucket] point to the fake structure by changing the bucket index in shared memory.
  4. Wait for the daily graceful restart (e.g., at 6:25AM) to trigger the arbitrary function call 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.

Apache runs worker processes with low privileges to handle web requests, while a main process runs as root. The workers share a memory area with the main process, and a worker can tamper with a value that the main process later uses without checking. When the server restarts, the main process follows a pointer from that tampered value and calls a function as root, letting the attacker run code with full control.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.