PHP2Shell CMS exploits across WordPress, Joomla and Drupal

PHP2Shell across WordPress, Joomla and Drupal: four-stage WordPress RCE, worker-steered Joomla RCE, one-worker Drupal disclosure without RCE, and the matched Joomla fixed control

The PHP2Shell exploit did not transfer unchanged between CMSs. In isolated labs, we achieved remote code execution (RCE) against WordPress and Joomla using different exploit chains. Selected Drupal PHP files disclosed process memory, but our tests did not achieve RCE.

Our first PHP2Shell article covered the underlying out-of-memory failures, stale PHP state, multipart triggers, and the difference between Apache mod_php and PHP-FPM. Here, we changed the application environment and asked what had to be rebuilt around the same vulnerability family.

The route, request lifecycle and Apache worker pool changed the exploit conditions. WordPress and Joomla reached command execution through different programs and worker-affinity strategies.

Drupal followed the same rule. We recovered useful address disclosures in a narrow one-worker setup, but the tested command-execution lifecycle was wrong. We stopped rather than stretch memory disclosure into an unsupported RCE claim.

Why each CMS needed a different exploit chain

Each successful PHP2Shell chain in this work needed the same broad ingredients:

  1. interrupt PHP while request-owned state was only partly cleaned up;
  2. keep the relevant Apache worker alive;
  3. send a later request to the same worker;
  4. reclaim or reinterpret the stale state;
  5. disclose enough process information to construct the final stage; and
  6. verify command execution instead of treating a crash or HTTP error as success.

That is a lifecycle model, not a portable exploit recipe. The application route controls the reachable PHP behaviour, surrounding allocations, disclosure channel and connection reuse. The web-server model determines whether the next request reaches the same process. A proxy or load balancer may add another scheduling boundary.

We developed a separate exploit chain for each CMS.

WordPress used four dependent exploit stages and additional connections to influence Apache worker scheduling. Joomla required separate memory-disclosure and command-execution stages, with each dependent request pair kept on one worker. Drupal disclosed memory through selected shipped PHP files, but the tested command-execution chain failed.

The chains used related PHP flaws, but differed in HTTP request bodies, application routes, worker scheduling and fixed-build controls. A final request from one CMS would not test the full chain against another.

Results from the three CMS environments

The table describes separate lab profiles. It is not an identical-environment benchmark, and it should not be read as a security ranking of WordPress, Joomla and Drupal.

The shared baseline was PHP 8.4.26 under Apache mod_php, a 128 MiB PHP memory limit and isolated Docker networking. The worker profiles were not the same. The recorded WordPress run used a 150-worker candidate pool with 149 holders, Joomla used measured five-worker and later 20-worker profiles, and Drupal was deliberately restricted to one worker. Those choices answered whether each application-specific chain could work and what scheduling it required. They do not support an apples-to-apples comparison of the CMSs. A security ranking would require rerunning all three through the same route, worker pool and pressure model.

Target profile Exploit chain Worker strategy Result Fixed-build control
WordPress 7.1.2, PHP 8.4.26, Apache apache2handler, 128 MiB PHP memory limit Four dependent exploit stages Kept 149 connections open to influence Apache worker scheduling while sending the four exploit stages Exactly one verified command callback in the recorded run; the target recovered and lab cleanup was verified The WordPress chain was not tested on a fixed PHP build, so this study has no WordPress-specific fixed-build result
Joomla 6.2.0, PHP 8.4.26, Apache prefork with mod_php Eight steps covering preparation, a disclosure pair, renewed preparation and a final command-execution pair Kept each dependent request pair on a persistent HTTP/1.1 connection and used worker steering or held-open connections Known five-worker active steering produced 7/7 verified command executions; natural scheduling produced 0/5 disclosures. A later unknown-worker experiment completed one verified chain on its third attempt after two earlier attempts stopped because the response or connection state was unsuitable A matched PHP 8.4.27 run used the same request builder, identical hashes for shared request bodies and the 20-worker/19-holder profile. It stopped at the disclosure consumer before address parsing or command-stage generation and recorded zero callbacks
Drupal 11.4.11, PHP 8.4.26, Apache prefork constrained to one worker The same broad eight-step family for disclosure and command-stage testing, followed by a tracked-variable lifecycle variant One worker only; we did not proceed to an unknown-worker campaign Selected directly executed shipped PHP files returned session values that decoded to 600,000-byte memory disclosures from which runtime bases were derived; no command marker or callback was observed. We rejected the later lifecycle variant after checking allocation identity and ordering The initial split trigger had affected/fixed comparisons, but the later eight-step Drupal chain was not repeated on PHP 8.4.27
Separate lab profiles with different routes and worker models. This is not a CMS product ranking.

How this compares with other PHP2Shell reporting

The new public reports help because they independently reinforce the same boundary: a published proof of concept is not a general-purpose exploit. Praetorian describes successful lab exploitation while stressing that the chain depends on the exact PHP build, memory limit and request-to-worker continuity. It also notes that an exposed phpinfo() page can reveal version, SAPI and build details that make target profiling easier.[5]

Wiz reports a similar gap from observed exploitation attempts. Their analysis found attacks reaching the memory-exhaustion trigger but often failing during the disclosure stage when the deployment differed from the public proof of concept. They also demonstrated successful exploitation in a controlled single-worker honeypot. That supports our distinction between proving the PHP primitive and establishing a reliable application-specific chain.[6]

WordPress: four exploit stages, many supporting connections

The WordPress exploit still had four stages, but getting each request to the right Apache worker took more work than it did in a single-worker lab.

In one test run, we confirmed that all four request bodies were received and that the exploit reached the intended code path. A new callback listener had no hits before the run and received exactly one command callback. We also accounted for all 336 connections made during the test, including probes, connections held open to influence worker scheduling, and the four exploit requests. The site responded normally afterwards, and the test environment shut down cleanly.

So “four-request exploit” would be misleading. There were four exploit requests, but many more connections were used to steer them to the right worker. We used 150 as a working estimate for the worker pool and kept 149 connections open. We did not measure the actual worker count remotely, and we did not test this approach behind a reverse proxy, a load balancer or on a busy production site.

This was a freshly installed WordPress 7.1.2 site using files shipped with WordPress: /wp-content/index.php for the disclosure and /index.php for the final stages. Neither route was custom. The successful run used our Apache/PHP lab setup and held-open connections. We did not measure how often it would work on other hosting setups.

WordPress RCE proof video

The video shows a fresh run in the same WordPress 7.1.2/PHP 8.4.26 lab setup and the victim-created uid=33(www-data) gid=33(www-data) groups=33(www-data) result. Play fullscreen to read the terminal text.

Fresh WordPress run with victim-side www-data proof.

Joomla: worker affinity changed the outcome

Joomla needed two related requests to reach the same Apache worker before we could disclose process memory. In a quiet pool of five workers, that did not happen on its own: none of five attempts produced a memory disclosure.

We then used four harmless requests to influence which worker handled the next request, recording the worker each time. Under that controlled setup, the memory-disclosure and command-execution chain succeeded in all seven trials, including three after restarting the web container. That is a result under controlled worker scheduling, not ordinary traffic.

Next, we tried a separate eight-stage chain without knowing the target worker in advance. We kept each dependent request pair on one persistent HTTP/1.1 connection: one pair for memory disclosure and another for command execution. Each pair needed to stay on the same Apache worker. A reverse proxy could send the requests to different backend workers.

That later test kept 19 connections open while assuming a pool of 20 workers; we did not measure the worker count remotely. The first two attempts stopped because the response or connection did not meet our test conditions. The third produced a memory disclosure and one command callback. The target recovered, and we closed the connections.

We used a fresh Joomla 6.2.0 installation and its shipped /includes/defines.php file. Direct access to that file worked in our Apache lab, but another site’s web-server configuration could block it. We did not test other Joomla deployments or releases.

Joomla RCE proof video

The video shows a separate one-worker Joomla 6.2.0/PHP 8.4.26 lab run and its victim-created uid=33(www-data) gid=33(www-data) groups=33(www-data) result. Play fullscreen to read the terminal text.

Fresh Joomla run with victim-side www-data proof.

Drupal: a real memory disclosure, but no RCE

In our one-worker Apache lab, we disclosed process memory from Drupal 11.4.11 but did not execute commands. The disclosure came from a shipped maintenance redirect and two documentation PHP files. They returned PHPSESSID values that decoded to 600,000 bytes. From the HTTP responses, we recovered the Zend heap and libphp base addresses. These are not normal Drupal routes; its supplied Apache rules can block direct requests to nested PHP files. The normal front controller returned only an ordinary session ID or a zero-byte leak.

We tried to use the disclosure for command execution. Some final requests returned HTTP 200 or 302, but no command marker appeared. We repeated the test without instrumentation and again disclosed memory while keeping the dependent requests on the same worker. There was still no marker. An HTTP response alone was not proof of remote code execution (RCE).

The traces explain why our later attempt to reuse stale session state failed. The stale reference pointed to a live POST string, not our forged table. PHP freed that string and placed a real table in the freed slot. Our forged bytes were inside a separate allocation, where the table could not be created. Changing the request fields did not fix that mismatch.

We demonstrated memory disclosure through those directly requested files in a one-worker lab, not Drupal RCE. We did not demonstrate the same leak through Drupal’s normal route or test multiple workers. This failed chain does not rule out other routes to RCE.

Drupal memory disclosure proof video

The video shows a fresh one-worker lab run against the shipped /core/rebuild.php file. Its HTTP response returned a PHPSESSID value decoding to 600,000 bytes, with 2,306 candidate pointers and derived Zend heap and libphp bases. Command execution was not attempted. Play fullscreen to read the terminal output.

Drupal lab memory disclosure: 600,000 decoded bytes and leaked process pointers; no command execution attempted.

Reproduction and evidence package

The reviewed article, media, sanitized result summaries and selected test-harness source are preserved in the private Fortbridge repository php2shell-cross-cms-research. Access remains restricted.

The repository’s replication notes describe the tested lab conditions, historical controller commands and what cannot be replayed from the selected source package. In outline:

  1. WordPress: build the pinned WordPress 7.1.2/PHP 8.4.26 Apache profile with a 128 MiB limit, expose it only on loopback, occupy 149 of the 150 prefork lanes, run one A1 → B1 → A2 → B2 chain with retries disabled, independently read the victim-created id marker, check the target still responds, then remove the labelled containers, network and relay.
  2. Joomla: build the pinned Joomla 6.2.0/PHP 8.4.26 Apache profile, use the shipped direct route documented in the private package, preserve each dependent pair on one persistent connection, apply the recorded five-worker steering or 20-worker/19-holder model, require a fresh callback or victim marker, run the matched PHP 8.4.27 refusal control, then tear down the isolated project.
  3. Drupal: build the pinned Drupal 11.4.11/PHP 8.4.26 one-worker profile, compare the normal front controller with the selected directly executable shipped files, require the 600,000-byte HTTP disclosure and independent base-consistency checks before attempting the command stages, record the absent proof as no RCE, and stop without promoting the rejected lifecycle variant.

What defenders should take from this

Patch the PHP runtime serving the site

The shared defect is in PHP. Updating WordPress, Joomla or Drupal without updating the PHP runtime does not address the underlying vulnerability family. Check the PHP build used by the web handler, not only the command-line interpreter. Distribution and managed-hosting backports also mean that a visible version string may not tell the whole story.

Do not treat worker complexity as a patch

Multiple workers, reverse proxies and load balancers can disrupt the process affinity required by the chains we tested. In the direct Apache lab profiles reported here, controlled worker scheduling and held-open connections kept dependent requests on the same worker. We did not establish the same control through arbitrary intermediaries or production traffic.

Worker complexity can make exploitation less reliable. It does not remove the PHP bug, and it is not a substitute for installing a fixed build.

Monitor request sequences, not one status code

The successful chains combined unusual multipart traffic, memory-limit failures, paired requests, long-held connections, large disclosure responses and worker churn. Each signal may be benign alone. Their order and repetition matter more than an isolated HTTP 500.

Treat temporary controls as partial

Blocking unusual multipart traffic, disabling session upload progress or changing memory-limit behaviour may interrupt known chain components, but these controls have costs and gaps. A fixed PHP build remains the durable control.

What exploit researchers should take from this

Adapting this exploit to another CMS requires understanding its request and worker lifecycle; copying payload bytes is not enough.

Separate the application route, the memory state needed by the producer and consumer, and the scheduling needed to revisit the same worker. A change in any one of these may require a different exploit chain.

Keep evidence levels separate as well. A fatal error proves a trigger. A memory disclosure proves a read or reinterpretation primitive. A fresh victim-side callback or marker proves command execution. Results from adjacent experiments do not become one stronger result simply because they look related.

References

  1. Fortbridge, PHP2Shell: out of memory to remote code execution. Background on the vulnerability family, SAPIs, triggers and the earlier vulnerable-versus-patched lab controls.
  2. Calif Research, PHP2Shell: a tale of two PHP remote vulnerabilities. Original technical research and disclosure write-up.
  3. Hacktron AI, php2shell: the exploitability gap between frontier and open models. Independent discussion of why a working chain does not automatically port across applications, SAPIs, proxies and worker layouts.
  4. PHP, PHP 8.4.27 release announcement. Upstream fixed release used by the matched Joomla comparator.
  5. Praetorian, PHP2Shell. Independent lab exploitation and analysis of build-specific offsets, memory limits, worker continuity and information disclosed by phpinfo().
  6. Wiz, PHP2Shell exploitation so far. Observed exploitation attempts, deployment-specific failure modes and controlled single-worker honeypot validation.

About Post Author