Is my PHP application affected by PHP2Shell, and how do I mitigate it?
A scanner or advisory feed reports CVE-2026-109618 (RCE via OOM corruption) on your serverShort answer
You are exposed when the PHP serving web requests is older than 8.2.35, 8.3.36, 8.4.27 or 8.5.12 on its branch, or when a distribution package is older than its vendor's fixed build. Check the web process, not only the command line. Updating PHP and restarting every worker is the only complete fix. The advisories give stop-gap settings that are not enough alone.
Fix it fast
1Find out which cause you have
Ask the web server itself which PHP it runs, because the command line can use a different PHP from the one that answers web requests. Put this one-line file in the web root, request it, and delete it at once. The output is the version followed by the SAPI name.
<?php echo PHP_VERSION, ' ', PHP_SAPI; # then, from a shell curl -s https://example.com/which-php.php2Match what you see, then jump to its fix
- 1
The output shows a version below 8.2.35, 8.3.36, 8.4.27 or 8.5.12, for example 8.3.30 apache2handler, and PHP was not installed from a Debian or Ubuntu packageAn upstream PHP build is older than the patched release of its branchFix - 2
The web check prints an old-looking number such as 8.3.6, but the package may already carry the fixA Debian or Ubuntu package is older than the vendor's fixed buildFix - 3
The first-step output ends with apache2handlerApache mod_php, the case the advisory confirmsFix - 4
php -v or dpkg shows the fixed build while the web check still prints an old oneThe package is upgraded, but the web process still runs the old PHPFix - 5
The server runs an affected PHP and the update is blocked or scheduled for laterYou cannot update today, so you need the documented stop-gap settingsFix - 6
The server ran an affected build while reachable from the internetYou need to know whether the server was already hitFix
- 1
What does the error look like?
A scanner or advisory feed reports CVE-2026-109618 (RCE via OOM corruption) on your serverA scanner or advisory feed reports CVE-2026-109619 (RCE via stale global state) on your serverThe web PHP version is below 8.2.35, 8.3.36, 8.4.27 or 8.5.12
Cause 1 of 6
An upstream PHP build is older than the patched release of its branch
1Check
Both advisories list every version below those four releases as affected and those four as patched. They name no patched upstream release for branches older than 8.2.
curl -s https://example.com/which-php.php2Fix
Update to the patched release or newer on the same branch, from the source you installed from or by rebuilding your image. Then restart the workers. The advisories call updating the only complete mitigation.
sudo systemctl restart php8.3-fpm3Verify
Request the which-php.php file again and read the version, then delete the file.
curl -s https://example.com/which-php.phpConfirmed by github.com
Cause 2 of 6
A Debian or Ubuntu package is older than the vendor's fixed build
1Check
Distributions ship the fix under their own package version, so the number PHP prints is not enough. Ubuntu lists php8.3 on 24.04 as fixed in 8.3.6-0ubuntu0.24.04.13, and Debian lists php8.2 on bookworm as fixed in 8.2.35-1~deb12u1 from the security archive. Compare the installed package version with the fixed version in your vendor's tracker.
dpkg -s php8.3-fpm | grep '^Version'
apt list --upgradable 2>/dev/null | grep -i php2Fix
Install the update from the distribution, then restart the workers.
sudo apt update
sudo apt install --only-upgrade php8.3-fpm php8.3-cli
sudo systemctl restart php8.3-fpm3Verify
dpkg now shows a version at or above the fixed one from the vendor's tracker.
dpkg -s php8.3-fpm | grep '^Version'Confirmed by ubuntu.com
Cause 3 of 6
Apache mod_php, the case the advisory confirms
1Check
For CVE-2026-109618 the advisory confirmed the flaw on Apache mod_php, where shutdown runs even when startup fails, and validated remote code execution over HTTP with default limits. FPM looks susceptible from source analysis but no complete exploit is shown. FrankenPHP is described as likely susceptible, and LSAPI as likely susceptible but unvalidated.
curl -s https://example.com/which-php.php2Fix
Patch whichever SAPI you run. On mod_php, restart Apache after the update so that every worker loads the new PHP.
sudo systemctl restart apache23Verify
Confirm the package version as in the previous cause, and read the web check again.
curl -s https://example.com/which-php.phpConfirmed by github.com
Cause 4 of 6
The package is upgraded, but the web process still runs the old PHP
1Check
The command line and the web server can use different PHP builds, and the advisories tell you to restart all workers after a configuration change, so treat an update the same way.
php -v
curl -s https://example.com/which-php.php2Fix
Restart the service that runs your PHP workers, and check that no second PHP install is the one wired to the web server.
sudo systemctl restart php8.3-fpm
sudo systemctl restart apache23Verify
The web check shows the build you expect.
curl -s https://example.com/which-php.phpConfirmed by github.com
Cause 5 of 6
You cannot update today, so you need the documented stop-gap settings
1Check
The advisories name settings that lower the risk. They state that updating is the only complete fix, and that no generic configuration removes the risk of CVE-2026-109619. Save this as ini-check.php to see what the web process uses now.
<?php echo ini_get('memory_limit'), ' ', ini_get('session.upload_progress.enabled'), ' ', ini_get('post_max_size');2Fix
Set these in the main PHP configuration, where the application cannot override them, then restart all workers. memory_limit=-1 is the primary configuration mitigation for CVE-2026-109618, and it also removes PHP's own memory ceiling, so keep it only until you patch. session.upload_progress.enabled=0 is for CVE-2026-109619. On PHP 8.5 also set fatal_error_backtraces=0. Keep post_max_size modest, lower max_input_nesting_level, and block multipart/form-data at the frontend if the application does not use it. Do not use RLIMIT_AS or RLIMIT_DATA, because they cause mmap failures that reach the vulnerable path.
; main php.ini, not .user.ini
memory_limit = -1
session.upload_progress.enabled = 0
; PHP 8.5 only
fatal_error_backtraces = 03Verify
Restart the workers and request ini-check.php again. Delete the file afterwards.
curl -s https://example.com/ini-check.phpConfirmed by github.com
Cause 6 of 6
You need to know whether the server was already hit
1Check
The impact in both advisories is unauthenticated code execution with the web worker's privileges. The advisory for CVE-2026-109619 warns that clean logs do not prove safety.
<?php echo ini_get('log_errors'), ' ', ini_get('error_log'), ' ', ini_get('error_reporting');2Fix
Patch first, so the hole is closed while you look. Then treat everything the web worker account can read or write as in scope of your review. The advisory suggests error logging with error_reporting=E_ALL in an isolated environment for auditing.
; isolated test copy only
log_errors = On
error_reporting = E_ALL3Verify
Save the check as log-check.php, request it, delete it, and confirm that logging is on and a log file is named. Then read that log for new entries.
curl -s https://example.com/log-check.phpConfirmed by github.com
How do I stop it coming back?
- Watch the php-src security advisories and your distribution's security tracker for the branch you run, and keep PHP on a supported branch.
- Keep a one-line way to read the real PHP version and SAPI of the web process, so an audit never relies on php -v alone.
- Run workers under an account that can read only what the application needs, since the impact is code execution as that account.
- Rebuild and redeploy images after each PHP security release instead of patching long-lived servers by hand.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Security
PHP LDAP in Laravel fails with Can't contact LDAP server over TLS
unable to get local issuer certificate
PHP's LDAP client uses OpenLDAP's settings.
3 causes, each with a fixSecurity
AuthenticationException: your certificate validation callback returned false
System.Security.Authentication.AuthenticationException
This message means a validation callback was installed, yours or one a library added, and it returned false.
3 causes, each with a fixSecurity
SSH to an EC2 instance fails with Permission denied (publickey,gssapi-keyex,gssapi-with-mic)
ec2-user@ec2-203-0-113-25.compute-1.amazonaws.com: Permission denied (publickey).
On EC2 this error almost always means the instance did not accept your key for that user.
3 causes, each with a fixSecurity
gcloud init cannot finish the sign-in step
Enter authorization code
gcloud init signs in through a browser.
3 causes, each with a fixSecurity
A GitHub Actions SSH deploy step cannot log in to the server
ssh: handshake failed: ssh: unable to authenticate
The runner reached your server but the server refused the login.
4 causes, each with a fixSecurity
SSH to GitHub asks to confirm the host, or hangs on that prompt
ED25519 key fingerprint is SHA256:
SSH has never seen github.com from this machine, so it asks you to trust the server key.
2 causes, each with a fix