How does PHP2Shell let strangers run code on servers?

The short answer

PHP2Shell is two flaws in how PHP handles memory that let someone with no login run commands on a web server. Updating PHP is the only full fix, and the workers need a restart.

Animated diagram: How does PHP2Shell let strangers run code on servers?

PHP2Shell

PHP is a programming language that runs on the web server. W3Techs finds it on 69.3 percent of websites whose server-side language is known. PHP2Shell is the nickname for two flaws inside PHP itself, CVE-2026-109618 and CVE-2026-109619. CVE stands for Common Vulnerabilities and Exposures, the public list of known security flaws. Each one is scored 9.2 Critical under CVSS (Common Vulnerability Scoring System) version 4.0.

The safer option here is simply a newer PHP. Fixed versions 8.5.12, 8.4.27, 8.3.36 and 8.2.35 came out on October 21, 2026. The PHP project says there are no complete mitigations and that updating is the only safe choice. The urgency is real. Amazon’s MadPot honeypots logged an exploitation attempt on 17 October, four days before disclosure, and Amazon now reports broad exploitation in the wild.

What PHP2Shell actually does

Both flaws give RCE (remote code execution) without a login. If an attack works, the attacker’s commands run with the rights of the web worker account. The first flaw strikes while PHP is still unpacking a request, before the site’s script gets control. If memory runs out at that moment, the OOM (out of memory) handler calls longjmp() and leaves half-finished work behind. The shutdown step then reads that broken state. Against Apache mod_php, full code execution was shown over HTTP before any site code ran. FrankenPHP is likely affected too. On PHP-FPM (FastCGI Process Manager), no complete exploit has been shown.

The second flaw lives in a worker that serves one request after another. The worker keeps global state that points into the current request’s memory. A fatal error, a failed require, a parse error, a timeout or an out-of-memory error can stop a request before cleanup. The memory is freed, but the pointer survives. A later shutdown warning can even refill state that was cleared. The next request on that worker then touches freed memory, a use-after-free. That can mean code execution or leaked memory.

How the update protects your site

  1. Fixed releases close both flaws. PHP 8.5.12, 8.4.27, 8.3.36 and 8.2.35 repair both CVEs. Linux distributions patch their own builds and keep their base number, so Ubuntu’s fixed package reads 8.3.6-0ubuntu0.24.04.13, not 8.3.36.
  2. A restart loads the fix. Restarting the services, for example php8.3-fpm and apache2, makes the workers run the patched version.
  3. Check the right version. php -v shows the command-line PHP, not the one serving web pages. On Ubuntu, dpkg -s php8.3-fpm | grep Version shows the installed web package.
  4. Config only partly helps. Setting fatal_error_backtraces=0 on PHP 8.5 or session.upload_progress.enabled=0 cuts some risk but does not close the flaws.

Patched code plus restarted workers removes both bugs. Everything else only narrows the path.

Hiding errors is not a fix

Many admins hide error messages on live sites, so it’s tempting to think that blocks PHP2Shell. It doesn’t. Hiding diagnostics with error_reporting, display_errors or @ does not help. The danger is in what PHP does with memory when a request breaks, not in whether anyone sees the message.

What to do

  • Check which PHP version serves your site today. In WordPress, look under Tools, Site Health, Info, Server for the PHP details.
  • Update to 8.5.12, 8.4.27, 8.3.36 or 8.2.35, or your distribution’s fixed package. On Ubuntu: sudo apt update && sudo apt install --only-upgrade php8.3* libapache2-mod-php8.3.
  • Restart the workers, for example php8.3-fpm and apache2, then confirm the version again.
  • Treat config changes as a stopgap only, never as a replacement for the update.

#PHP2Shell#CVE2026109618#CVE2026109619#PHP#PatchNow#WordPress#RCE#WebSecurity#CyberSecurity#InfoSec

Watch it in 60 seconds