How a PHP Use-After-Free Bug Forced Government Sites Offline
This article explains how a PHP use-after-free vulnerability allows attackers to execute arbitrary code by exploiting memory management flaws in worker processes, detailing the attack chain from crafted file uploads to pointer corruption and why it prompted governments to take sites offline.
Reading font

Incident Background
Government agencies in Finland, the Netherlands, and the Wikimedia Foundation temporarily shut down websites after two security vulnerabilities were discovered in PHP. Because a vast portion of the web runs on PHP, the impact was global.
PHP Worker Process Memory Model
To handle thousands of concurrent visitors, a PHP server spawns multiple worker processes. Each process handles requests sequentially — for example, first John's request, then Allen's. For every request, PHP allocates temporary memory (e.g., a 128 MB limit) that is freed when the request finishes. However, the worker process itself retains a persistent memory space that survives across requests and may hold pointers to the temporary request memory.
Normal Request Cleanup
Under normal operation, when a request ends, PHP runs cleanup routines that properly clear any pointers stored in the persistent process memory, preventing dangling references.
The Vulnerability: Use-After-Free (UAF)
The flaw manifests only in an exceptional code path. An attacker sends a crafted file-upload request. During processing, PHP places internal data in the request's temporary memory at address 500 and stores a pointer to that address in the worker's persistent memory.
The attacker then forces the request to exceed the memory limit at a precise moment. PHP detects the over-limit condition and immediately terminates the request, freeing the temporary memory — but because the termination is abrupt, the normal cleanup code never runs. The pointer in the persistent memory remains, still pointing to address 500, even though that memory has been released.
Exploitation Walkthrough
Attacker sends a second request to the same worker process, containing the string AAAA.
PHP needs memory for the new request and may reuse the just-freed block at address 500, writing the attacker's AAAA there.
The stale pointer in persistent memory still points to address 500, but the content is now attacker-controlled.
When PHP later dereferences that pointer, it reads AAAA as if it were legitimate internal data and bases subsequent operations on it.
Impact and Severity
In the worst case, this causes the worker process to crash (denial of service). However, researchers found that by carefully crafting the injected data and combining the UAF with other exploitation techniques, an attacker can achieve arbitrary code execution on the server, gaining full control. This elevates the issue from a service disruption to a critical server compromise.
Mitigation
The definitive fix is upgrading to a PHP version that includes the security patches. For organizations unable to upgrade immediately — such as some government agencies — taking the affected sites offline serves as an emergency risk-avoidance measure, despite the service interruption.
About this article
For attribution, corrections or content rights, contact