Skip to content
Memory corruption Write-up Advanced

PHP-FPM Local Root Vulnerability

PHP-FPM stores its main scoreboard, including an array of pointers to per-worker scoreboards, in shared memory that low-privilege workers can write to. A worker can therefore redirect those pointers so the root main process reads or writes outside the shared segment, and by chaining this with other bugs an attacker with code execution in a worker can escalate to root.

ambionics.io

Published on ambionics.io

Two years ago we published CARPE DIEM, an Apache HTTPd local root vulnerability. Today we are releasing the details of a similar vulnerability that affects PHP-FPM.

The author, on ambionics.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

Likely the main scoreboard, including the procs pointer array, is placed in shared memory writable by unprivileged workers, so the root process dereferences attacker-controlled pointers.

Impact

A low-privilege user such as www-data could escalate to root, though the exploit needs a separate PHP sandbox escape and careful timing to avoid crashing the main process.

What the attacker needed

Code execution in a worker (sandbox escape); ability to spawn and kill workers; timing control over requests

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.

PHP-FPM is the helper program that runs PHP pages for a web server. It has one privileged boss process and several unprivileged worker processes that handle requests. The boss keeps a shared list of pointers describing each worker, and because workers can write to that shared list, a compromised worker can trick the boss into touching memory it should never touch, which can lead to full control of the machine.

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.