Post

PHP CVE-2026-109618: How to Fix Exploited php2shell Flaws

PHP fixed php2shell (CVE-2026-109618, CVE-2026-109619) on Oct 21; CISA lists both as exploited. Find the PHP your site runs and move to the Nov 19 releases.

PHP CVE-2026-109618: How to Fix Exploited php2shell Flaws

On October 21, PHP released its first fixes for two flaws known together as php2shell, CVE-2026-109618 and CVE-2026-109619. Under certain conditions, an attacker can execute code remotely without logging in, and CISA has added both flaws to its Known Exploited Vulnerabilities catalog.

If you upgraded in October, also check whether you have the November 19 follow-up fixes. That depends on your PHP branch or distribution package.

Based on php.net, the security advisories PHP publishes on GitHub (GHSA), the PHP Foundation, CISA, and NVD, checked on 2026-11-23 (Taipei time). Fixed versions and exploitation status may change, so use the latest official information.

Use this chart to prioritize updates. In the chart, “November release” means your branch’s November 19 release or anything later, including a distribution package that has the fixes it needs. Sites that serve only internal users still handle web requests, so they follow the “Yes or unsure” branch too.

flowchart TD
  A[PHP on this host] --> B{"Handles web requests (incl. internal)?"}
  B -->|No| C[Add to routine updates]
  B -->|"Yes or unsure"| D{"Already on November release?"}
  D -->|Yes| E[Confirm processes replaced]
  D -->|No| F{"8.2 or later?"}
  F -->|Yes| G[Upgrade and restart now]
  F -->|"8.1 or earlier"| H[Migrate or vendor patch]
  G --> E

php2shell affects PHP’s memory management and error handling

According to the PHP Foundation, almost every request goes through these two parts of PHP, so the fixes had to close the flaws while keeping existing applications compatible.

CVEWhere it goes wrongWhere remote code execution is confirmed
CVE-2026-109618When memory runs out (OOM), PHP aborts the work in progress. Request data may be only half initialized, yet cleanup treats it as validWith Apache mod_php’s default settings, a request can trigger it before any application code runs
CVE-2026-109619After a request ends, PHP’s global state still points to freed memory, and the next request in the same worker uses itDemonstrated on mod_php. The path through session upload progress is verified on both mod_php and PHP-FPM

A worker is the process that actually handles requests. Bugs like CVE-2026-109619, which use memory that has already been freed, are called use-after-free.

CVSS is a common scale for rating vulnerability severity. Both flaws score 9.2 (Critical) on CVSS 4.0, with identical ratings on every metric. Attack complexity is rated high, and an attack needs specific preconditions.

Check any PHP installation that handles web requests

Here, SAPI refers to the interface PHP uses to receive requests from a web server. php.net lists PHP-FPM, Apache mod_php, php-cgi, FrankenPHP, and LiteSpeed as affected SAPIs. The PHP project considers mod_php the highest risk among them.

mod_php is a PHP module that Apache loads directly. PHP-FPM is a separate pool of PHP processes, and servers such as nginx forward requests to it.

Two official documents give different answers on whether CVE-2026-109618 allows remote code execution on PHP-FPM:

SourceWhat it says about PHP-FPM
PHP Foundation (October 21)Remote code execution confirmed through an application-level path
GHSA-w8hw-w9fx-j79w (updated November 3)Judged affected based on source code analysis, but no complete FPM-specific demonstration yet

In my judgment, running FPM is no reason to patch later, because remote code execution through CVE-2026-109619 has already been verified on FPM.

CISA listed both as known exploited five days after disclosure

CISA’s Known Exploited Vulnerabilities catalog (KEV) lists flaws with evidence of exploitation in the wild.

DateEvent
October 20php.net announces an upcoming major security update
October 218.5.12, 8.4.27, 8.3.36, and 8.2.35 released, and CISA issues an alert
October 23php.net adds a note about session upload progress
October 26CISA adds both CVEs to KEV
November 198.5.13, 8.4.28, 8.3.37, and 8.2.36 released with follow-up fixes

According to the PHP Foundation, a research team mistakenly published a demonstration video the day before disclosure, and proofs of concept (PoCs) began to appear. By the October 21 disclosure, the PHP security team had found no working exploit among the PoCs it reviewed. When CISA added them to KEV on October 26, that meant it had evidence of real-world exploitation.

Check which PHP version your site actually runs

php -v only shows the version of the command-line (CLI) PHP. Your site may use a different package and version, with different configuration files.

So run the checks below on the host or container your site actually uses, and apply the mitigation settings there too.

1. Find the SAPI

1
ps -eo pid,user,args | grep -E '[p]hp-fpm|[a]pache2|[h]ttpd|[l]sphp|[f]rankenphp|[p]hp-cgi'

If you see php-fpm: master process, PHP-FPM is running on the host. If the host runs multiple sites or FPM versions, find the socket or port your site’s configuration sends requests to. The FPM pool listening there is the one that handles your site.

If you see apache2 or httpd, use these commands to check whether Apache loads the PHP module:

1
2
apache2ctl -M 2>/dev/null | grep -i php
httpd -M 2>/dev/null | grep -i php

The first line is for Debian and Ubuntu, and the second for the RHEL family. Output of php_module (shared) means Apache is configured to load mod_php. If the host also runs PHP-FPM, check the site’s VirtualHost (the configuration block for one site) to see whether mod_php or PHP-FPM handles its requests.

2. Check the version of the PHP that serves your site

PHP-FPM binary names often include the version, such as php-fpm8.3. Find which executable the FPM process from the previous step runs, then check its version.

1
2
ls /usr/sbin/php-fpm* /usr/local/sbin/php-fpm 2>/dev/null
php-fpm8.3 -v

Replace php-fpm8.3 with the executable you found. If the output shows (fpm-fcgi), you are looking at the FPM build. If you just upgraded the package, also follow “Restart PHP after upgrading” below to confirm the running processes have loaded the new files.

mod_php has no separate binary, so check its package version in step 3. If your site sends the X-Powered-By header, you can also see the version from outside:

1
curl -sI https://example.com/ | grep -i x-powered-by

According to the expose_php docs, when this setting is on, responses carry an X-Powered-By header with the running PHP version. For PHP 8.5.13, the header reads X-Powered-By: PHP/8.5.13.

Production sites may disable expose_php, so check on the server if the header is absent. If you use distribution packages, only the full package version tells you whether the fix is installed.

3. On distributions, check the full package version

Run the one line that fits your system:

1
2
3
dpkg -l | grep -E 'php[0-9.]*-(fpm|cli|cgi|common)|libapache2-mod-php'
rpm -qa | grep -E '^php'
apk info -v | grep -E '^php[0-9]+'

The first line is for Debian and Ubuntu, the second for the RHEL family, and the third for Alpine. Compare the result with the distribution table in the next section.

CISA warns that PHP is often bundled inside other software, where it is easy to miss. Count containers, hosting control panels, and packaged applications too. For containers, run the same checks inside the container.

For upstream PHP, install the November 19 release or later

BranchOctober 21November 19 (target)
8.58.5.128.5.13
8.48.4.278.4.28
8.38.3.368.3.37
8.28.2.358.2.36

The October security releases were the first round of fixes for both flaws. The November releases came out on PHP’s four-week release cycle and carry the October fixes forward.

The November releases also fix two flaws of the same class as CVE-2026-109619. GHSA rates both Critical 9.2:

  • CVE-2026-129481: GHSA traces it to an incomplete fix for CVE-2026-109619, a gap left by the October fix. It affects upstream PHP 8.3, 8.4, and 8.5 before the November versions in the table.
  • CVE-2026-129182: affects PHP 8.5 releases before 8.5.13. The 8.5.12 fix clears a piece of global state, but the shutdown sequence that runs afterward can write it back.

Both GHSAs say no one has yet demonstrated code execution through these two flaws. php.net also says the issues rated Critical in November need non-default settings or uncommon environments. I would still go straight to the November release and pick up all these fixes at once.

The PHP 8 ChangeLog lists every fix in the batch. PHP 8.2 stops receiving security updates on 2026-12-31, so if you still run it, start planning a move to a newer branch.

CVE-2026-129289 depends on whether your front end reuses FastCGI connections

The November releases also fix a PHP-FPM request smuggling flaw, CVE-2026-129289, which GHSA rates Critical 9.2. In request smuggling, an attacker hides a second request inside the body of the first, and the back end handles it as a separate request.

GHSA says the bug has been present since PHP 5.6.0, so PHP 8.2 is affected too. Unlike the two flaws above, GHSA describes a demonstrated attack that executes code on PHP-FPM.

FastCGI is the protocol that front ends such as nginx use to pass requests to PHP-FPM. According to GHSA, when an application opens php://input (the stream that reads the request body) without reading it to the end, PHP does not discard the rest of the body. If the front end reuses the connection, PHP-FPM may parse the leftover bytes as a new FastCGI request.

That forged request controls parameters such as SCRIPT_FILENAME and PHP_ADMIN_VALUE. GHSA says an attacker can use it to run their own PHP code as the worker account. The attack needs both of these conditions:

  • The front end reuses backend connections. Examples are nginx with fastcgi_keep_conn on, Apache mod_proxy_fcgi with enablereuse=on, or HAProxy keeping FastCGI connections open.
  • Some path in the application opens php://input without reading it fully. GHSA notes that some frameworks create this stream before routing or authentication, so even endpoints that ignore the body count.

GHSA states that standard nginx and Apache configurations, which close the FastCGI connection after each request, are not affected by the demonstrated attack. LSAPI, used by LiteSpeed, can also leave body bytes behind and disrupt later requests, but GHSA does not establish code execution through LSAPI.

Check whether nginx or Apache reuses connections:

1
sudo grep -rn -E 'fastcgi_keep_conn|enablereuse' /etc/nginx /etc/apache2 /etc/httpd 2>/dev/null

If the output shows fastcgi_keep_conn on or enablereuse=on, connection reuse is on. Check HAProxy and other front ends separately.

Even without connection reuse, upgrade to the November release, because the same batch has other Critical fixes. If you cannot upgrade yet, see “CVE-2026-129289: turn off connection reuse in the front end” below.

As of the check date, CVE-2026-129289 is not in CISA’s KEV catalog. Branches 8.1 and earlier have no official fix, so move to a supported branch or check with your distribution or LTS vendor.

8.1 and earlier have no official fixed release

The PHP project no longer releases updates for 8.1 and earlier. Because these flaws are so severe, the security team still provided minimal source patches for 7.4, 8.0, and 8.1, for people who build PHP themselves.

Some distributions and long-term support (LTS) vendors also carry the fixes over to these old versions, so check with your vendor. CISA recommends taking systems offline until they can be patched if they cannot install an update or are still running an unpatched version of PHP 8.1 or earlier.

Distribution packages

Distributions often carry fixes over to older packages while keeping the original upstream version number. This is called a backport. php.net says distributions and LTS vendors received the fixes in advance.

The table lists the full version of the first package to include each fix. Compare each column separately: if your installed version is the same as or newer than the one in a column, you have that column’s fix.

The November column covers CVE-2026-129289 and CVE-2026-129481. According to GHSA, the internal session field behind CVE-2026-129481 was added in PHP 8.3, so 8.2 and earlier are not affected by it. CVE-2026-129289, however, dates back to PHP 5.6.0, so 8.2 and 8.1 packages need the update too.

“No secdb entry yet” means Alpine’s security database, secdb, does not list the status of these two November flaws yet, so check with Alpine.

DistributionPackagephp2shell (October)November follow-up fixes
Debian 12php8.28.2.35-1~deb12u1 (DLA-4848-1)8.2.36-1~deb12u1 (DLA-4916-1)
Debian 13php8.48.4.27-1~deb13u1 (DSA-6574-1)8.4.28-1~deb13u1 (DSA-6641-1)
Ubuntu 22.04php8.18.1.2-1ubuntu2.28 (USN-8948-1)8.1.2-1ubuntu2.29
Ubuntu 24.04php8.38.3.6-0ubuntu0.24.04.13 (USN-8948-1)8.3.6-0ubuntu0.24.04.14
Ubuntu 26.04php8.58.5.4-0ubuntu1.5 (USN-8948-1)8.5.4-0ubuntu1.6
RHEL 8php:8.2 module8.2.35-1.module+el8.10.0 (RHSA-2026:87073)8.2.36-1.module+el8.10.0 (RHSA-2026:101276)
RHEL 9php:8.3 module8.3.36-1.module+el9.8.0 (RHSA-2026:87079)8.3.37-1.module+el9.9.0 (RHSA-2026:102226)
RHEL 10php8.3.36-1.el10_2 (RHSA-2026:87070)Affected, not yet fixed
RHEL 10php8.48.4.27-1.el10_2 (RHSA-2026:87071)8.4.28-1.el10_3 (RHSA-2026:100821)
Alpine 3.22php828.2.35-r0No secdb entry yet
Alpine 3.22php83, php848.3.36-r0, 8.4.27-r0No secdb entry yet
Alpine 3.23php83, php84, php858.3.36-r0, 8.4.27-r0, 8.5.12-r0No secdb entry yet
Alpine 3.24php83, php84, php858.3.36-r0, 8.4.27-r0, 8.5.12-r08.3.37-r0, 8.4.28-r0, 8.5.13-r0

The versions come from Debian, Ubuntu, Red Hat, and Alpine secdb. The November column comes from each vendor’s CVE-2026-129289 and CVE-2026-129481 pages, such as Debian’s pages for CVE-2026-129289 and CVE-2026-129481, and Ubuntu’s page for CVE-2026-129481. For other RHEL module streams, such as php:7.4 on RHEL 8, see the full list on the Red Hat page.

The other follow-up flaw, CVE-2026-129182, affects only PHP 8.5. Ubuntu 26.04 fixes it in 8.5.4-0ubuntu1.6. As of the check date, Alpine’s secdb had no entry for it.

As of the check date, php on RHEL 10 had no fix for CVE-2026-129289 or CVE-2026-129481 in the standard releases. EUS (Extended Update Support) releases use different fixed versions, so check Red Hat’s CVE page.

Until a fix for CVE-2026-129481 is available, GHSA recommends avoiding fatal errors during session cleanup. A fatal error is one that makes PHP abort execution. If you run PHP-FPM, the pm.max_requests setting below can also reduce exposure for now.

Windows builds and Docker images

On October 26, the Windows builds were rebuilt separately as 8.5.12-1 and similar versions. The rebuild fixes a flaw in the Brotli compression library, and the PHP version itself stays the same.

When I checked, the official Docker images php:8.5-apache and php:8.5-fpm were already 8.5.13, built on November 19. With containers, pull the new image and redeploy. Restarting an old container does not update it.

Tags without a branch, such as php:latest and php:fpm, already point to 8.6.0. It came out the same day as the November releases, and its ChangeLog also lists the fixes for CVE-2026-129289, CVE-2026-129481, and CVE-2026-129182. To stay on your current branch, name the version explicitly, for example php:8.4-fpm.

Restart PHP after upgrading, then confirm no old processes remain

Upgrading a package only replaces files on disk. PHP processes that are already running may keep using the old files they loaded, so confirm that the processes handling requests have loaded the new ones. GHSA also calls for restarting every PHP worker after applying mitigation settings.

According to proc_pid_exe(5) and proc_pid_maps(5), when the old file has been removed from its path, /proc appends (deleted) to that path. The table lists the usual reload (a restart that does not fully stop the service) for each service, and where the marker shows up while the old file is still in use.

ServiceUsual reloadWhile the old file is still in use
Apache mod_phpapache2ctl -k gracefullibphp.so in maps is marked (deleted)
PHP-FPMUSR2 to the masterthe php-fpm that exe points to is marked (deleted)

Whether a reload moves every process to the new file, and what the services are called, varies by distribution. So I would restart the service that handles the site’s PHP requests. If nginx is the front end, restart PHP-FPM behind it; restarting nginx does not replace PHP processes.

Use the first line for PHP-FPM and the second for Apache mod_php:

1
2
sudo systemctl restart php8.3-fpm
sudo systemctl restart apache2

Use the actual service names on your system, such as php-fpm and httpd on the RHEL family. A restart can interrupt existing connections, so plan it into your maintenance window.

After the restart, use these two lines to find processes still using old files:

1
2
sudo grep -l 'libphp.*(deleted)' /proc/[0-9]*/maps 2>/dev/null
sudo ls -l /proc/[0-9]*/exe 2>/dev/null | grep -E 'php.*\(deleted\)'

The first line finds processes that still have a removed libphp loaded, including Debian’s libphp8.3.so. The second finds processes still running a removed PHP executable, such as php-fpm, php-cgi, or lsphp.

If neither line prints anything, no process using a removed old file was found. Then confirm that the service works and, with the version checks above, that your site runs a patched PHP.

If you cannot upgrade yet, the official mitigations are all incomplete

php.net states plainly that only updating is a complete fix. The settings below only block specific attack paths. Applying them does not mean the system is safe.

CVE-2026-109618: turn off PHP’s own memory limit

  • Set memory_limit=-1 in a way the application cannot override, such as php_admin_value in an FPM pool or Apache configuration. Also confirm that no other pool, directory, or application setting adds a limit back. This only stops attackers from deliberately triggering an out-of-memory error by hitting a fixed limit; low-level allocation failures still reach the vulnerable path.
  • Lower post_max_size. Use 8M if you do not need file uploads and 32M if you do, and keep upload_max_filesize below it.
  • At the web server or proxy layer, limit decoded request size, field count, multipart part count, header count, and nesting depth. Also limit requests without a usable Content-Length. Multipart is the request format forms use to upload files, and GHSA also suggests blocking it at the front end if the application does not use it.
  • Use a container or cgroup memory limit to protect availability, ideally set up to kill only the worker that goes over it. A cgroup is the Linux mechanism that limits process resources. Do not use RLIMIT_AS or RLIMIT_DATA instead, because they make memory allocations fail and trigger exactly the vulnerable path.

My understanding is that memory_limit=-1 lets a single request use a large amount of memory, so php.net lists the cgroup limit in the same group.

CVE-2026-109619: close the two confirmed paths

  • Set session.upload_progress.enabled=0 and restart every worker. Set it where it applies before the request is parsed: php.ini, the FPM pool, or the server configuration, not ini_set() or FPM’s .user.ini. This only blocks the confirmed session path.
  • On PHP 8.5, also set fatal_error_backtraces=0 and restart every worker. This only blocks the confirmed fatal error backtrace path.
  • Remove invalid or deprecated settings that are applied per request and produce warnings. Hiding the warnings with error_reporting, display_errors, or @ does not help.
  • Fix fatal errors and execution timeouts that an attacker can trigger, including errors in callbacks, upload or import handling, and cleanup routines.
  • GHSA also recommends setting pm.max_requests=1 in PHP-FPM and restarting the service. This replaces each worker after one request. The trade-off is constantly starting new workers, which adds overhead.

The November release turns session upload progress off by default. According to GHSA-658j-r8rw-q6mx, a configuration file that explicitly turns it on still overrides the new default. So after you upgrade, confirm that session.upload_progress.enabled is actually off in the PHP that handles requests.

GHSA also names another exposure: front-end servers such as nginx that pass settings to FPM in each request with PHP_VALUE or PHP_ADMIN_VALUE. If those values produce warnings, FPM may be affected by CVE-2026-109619.

That is why mitigation settings belong in the pool file instead of being sent from the front end. First check whether your front end sends settings this way:

1
sudo grep -rn -E 'PHP_(ADMIN_)?VALUE' /etc/nginx /etc/apache2 /etc/httpd 2>/dev/null

Put the settings in the pool or Apache configuration

For PHP-FPM, put the settings in the pool your site uses. For the default www pool, PHP 8.3 on Debian or Ubuntu uses /etc/php/8.3/fpm/pool.d/www.conf. RHEL systems commonly use /etc/php-fpm.d/www.conf.

In both examples, use the fatal_error_backtraces line only with PHP 8.5.

1
2
3
4
php_admin_value[memory_limit] = -1
php_admin_value[session.upload_progress.enabled] = 0
; The next line applies to PHP 8.5 only
php_admin_value[fatal_error_backtraces] = 0

For mod_php, put them in Apache’s main configuration or a VirtualHost:

1
2
3
4
php_admin_value memory_limit -1
php_admin_flag session.upload_progress.enabled off
# The next line is for PHP 8.5 only
php_admin_flag fatal_error_backtraces off

php_admin_value and php_admin_flag are server settings. Application code cannot override them with ini_set(), which just returns false. See the FPM pool configuration and Apache configuration changes docs.

php -i and php-fpm -i read the CLI or FPM master ini, so they do not show php_admin_* from a pool or Apache. To confirm that PHP-FPM reads the pool settings, run it with -tt to test the configuration and print what it parsed, then filter for php_admin_value:

1
sudo php-fpm8.3 -tt 2>&1 | grep php_admin_value

After changing the settings, follow “Restart PHP after upgrading” to restart the service. Then use a real request to your site to confirm that memory_limit is -1 and that ini_set('memory_limit', '128M') does not change it.

CISA also notes that a web application firewall (WAF) may give partial protection before you patch.

CVE-2026-129289: turn off connection reuse in the front end

Until you upgrade, GHSA recommends making the front end close the FastCGI connection after every request:

  • In nginx, do not set fastcgi_keep_conn on. The nginx docs state that it is off by default.
  • In Apache mod_proxy_fcgi, do not set enablereuse=on.
  • In HAProxy and other FastCGI front ends, close the backend connection after each request.

Per the docs, nginx keepalive connections to FastCGI servers need fastcgi_keep_conn on to work. Turning it off restores the default, where each request opens a new connection. Reload nginx or Apache after changing the configuration.

GHSA also warns about two things:

  • Making the application always read php://input to the end blocks the demonstrated case. Error paths, resource exhaustion, and shutdown can still break it, so it is not reliable as the only mitigation.
  • Do not expose PHP-FPM or LSAPI listeners directly to untrusted networks.

Check which TCP addresses PHP-FPM and LSAPI listen on:

1
sudo ss -ltnp | grep -E 'php-fpm|lsphp'

An address of 127.0.0.1 or [::1] accepts only local connections. Any other address may be reachable from other hosts, so limit the sources with a firewall or the pool’s listen.allowed_clients. Pools that listen on a Unix socket do not appear in this output.

Check for signs of compromise after patching

If the host served public PHP traffic before you patched it, look for signs of compromise from that period.

CISA recommends watching for PHP workers that start a shell or download tools. This command lists every current process under one account, then filters out PHP-FPM and Apache themselves by name.

1
ps -u www-data -o pid,ppid,user,lstart,args | grep -v -E 'php-fpm|apache2|httpd'

Replace www-data with the PHP worker’s account; apache and nginx are also common. The command lists processes by account, not by parent. Even if a background process has left the worker and been taken over by PID 1 (the system’s first process), it still shows up as long as it runs as the same account.

A listed process is not necessarily a compromise, since scheduled jobs may use the same account. This command only shows current processes, so for past activity, check the records from auditd or your endpoint protection tool. CISA also provides SIGMA detection rules; SIGMA is a common format for log detection rules.

GHSA warns that a log without errors does not mean you are safe. Older logs may not capture deprecation-level messages, and PHP may fail before it writes a message.

According to GHSA, the confirmed impact is that an attacker can execute code with the privileges of the web worker account. If I found suspicious signs, I would treat the host as compromised:

  1. Restrict its external network access, and keep the logs and disk snapshots.
  2. Rebuild the host from a trusted clean image.
  3. From a clean environment, rotate the credentials the worker could read, such as database passwords, API tokens, and application secrets.

If nginx is your front end, check the nginx flaw too

PHP-FPM often sits behind nginx. On November 18, nginx also fixed an HTTP/2 flaw that allows remote code execution. See nginx CVE-2026-123007: Upgrade Now If HTTP/2 Is On.

I also ran into the “package updated, old service still running” problem in CVE-2026-123158: OpenSSH Password Bypass on Alpine (musl).

Main sources

This post is licensed under CC BY 4.0 by the author.