+420 737 981 440

PHP2Shell: a critical security flaw in PHP and what to do right now

In October 2026, two critical flaws were disclosed in PHP itself, together known as PHP2Shell. A single crafted request lets an attacker run their own commands on the server – no login needed, and no matter how well your application is written. Fixed versions 8.5.12, 8.4.27, 8.3.36 and 8.2.35 were released on 21 October, and the flaws are already being exploited. PHP 8.1 and older will not get an official update.

What happened

Most security flaws you hear about live in a specific application or library – an online shop, a CMS, a plugin. PHP2Shell is different: the bug is in PHP itself, in the part that processes an incoming request before the first line of your code runs. That makes practically every website on unpatched PHP vulnerable, even one that only prints “Hello world”.

The PHP project released fixes on 21 October 2026. Both flaws are rated 9.2 out of 10 and lead to unauthenticated remote code execution (RCE). Details leaked before the planned disclosure, proof-of-concept exploit code is public, and security companies report mass scanning and successful attacks. On 26 October, the US agency CISA added CVE-2026-109618 to its catalogue of known exploited vulnerabilities.

Explained for owners and managers

Imagine an attacker submits a form to your website that looks like an ordinary request but is cleverly constructed. While processing it, PHP hits the configured memory limit, aborts, and during clean-up mistakenly uses data the attacker planted. The result: the server runs a command of the attacker’s choosing – for example, downloading and starting malware.

The attacker gets the same rights as your website: they can read the database including customer data, change content, send e-mails in your name or leave a back door on the server for later. If you process personal data, a breach may also mean you have to report the incident under GDPR.

The good news: the fix is a regular PHP update. On current versions it is usually a routine job of a few minutes that changes nothing in your application. The trouble is for anyone still running old PHP.

Technical summary for developers and admins

CVE-2026-109618 – memory corruption when memory_limit is exceeded

When memory_limit is exceeded, PHP aborts the request with longjmp(). If this happens in the middle of input parsing (typically multipart/form-data or long field names in $_POST), the hash table is left with a counted but uninitialised element. At request shutdown PHP treats it as a valid value, and because memory still holds data from the attacker’s earlier allocations, it can call a destructor the attacker chose. A successful attack has to bypass ASLR; public exploits use a memory leak via the PHPSESSID cookie.

CVE-2026-109619 – stale state between requests

Some request-owned state survives after its memory is freed, for example after a fatal error, and the next request handled by the same worker uses it (use-after-free). The confirmed paths go through session upload progress (session.upload_progress, enabled by default and active even if the application never calls session_start()) and, in PHP 8.5, through the new fatal_error_backtraces.

Who is affected

  • All web SAPIs – PHP-FPM, Apache mod_php (highest risk), php-cgi, FrankenPHP, LiteSpeed. Plain CLI scripts and cron jobs are not vulnerable unless they accept HTTP requests.
  • Versions – PHP 8.5 before 8.5.12, 8.4 before 8.4.27, 8.3 before 8.3.36, 8.2 before 8.2.35 and all older branches. According to Google, everything from PHP 5.4 onwards is affected.
  • PHP 8.1, 8.0 and 7.4 – there will be no official release; the PHP project only published minimal source patches. Whether you get them depends on your distribution or hosting. There is no fix for PHP 7.3 and older.

What to do right now

1. Find out which PHP version you really run

php -v in a terminal is not enough – the web server may use a different version than the command line. Check the PHP-FPM version (php-fpm8.4 -v, php-fpm -v) or temporarily use phpinfo() on a non-public URL. On shared hosting, look in the control panel or ask your provider.

2. Update and restart

On supported versions, install the patched packages and restart PHP-FPM or Apache – as long as old processes run, so does the old bug. Debian, Ubuntu or RHEL often backport the fix into a package with the same version number, so the changelog matters, not the number:

apt-get changelog php8.4-fpm | grep -E "CVE-2026-10961[89]"
rpm -q --changelog php-fpm | grep -E "CVE-2026-10961[89]"

Rebuild Docker images from an updated base image; restarting the container is not enough.

3. If you can’t update immediately: temporary protection

The following settings, recommended by CERT-EU, block the known attack paths. They do not replace the fix, they only reduce the risk until you deploy it. Set them globally in php.ini or in the FPM pool via php_admin_value, not via ini_set() or .user.ini, and restart every worker:

session.upload_progress.enabled = 0
fatal_error_backtraces = 0   ; PHP 8.5 only
post_max_size = 8M           ; 32M if the site accepts file uploads
upload_max_filesize = 4M     ; always smaller than post_max_size

CERT-EU also recommends disabling session.upload_progress because of a further flaw, CVE-2026-115560, announced by the PHP project on 23 October, whose fix will only come with the next release. Keep this setting in place even after updating, until that fix is out – the vast majority of applications don’t use session upload progress.

Another recommended safeguard is memory_limit = -1 combined with a memory limit at the container or cgroup level. It affects server stability, so deploy it carefully. On the other hand, do not use ulimit -v, RLIMIT_AS or LimitAS= – they trigger exactly the allocation failures the attack relies on. Limits on request size and number of parts at the web server or WAF level help too.

How to tell if someone tried to attack you

An attack doesn’t have to leave an obvious trace – a successful break-in often produces only a few error messages and then silence. Look mainly for:

  • PHP error log entries Allowed memory size of … bytes exhausted … in Unknown on line 0 – “Unknown on line 0” means memory ran out while parsing input, not in your application,
  • worker crashes in the Apache or FPM log (Segmentation fault), especially in bursts,
  • unusual multipart/form-data requests with PHPSESSID and PHP_SESSION_UPLOAD_PROGRESS fields or hundreds of nested names like files[…][a][a][a],
  • responses with a PHPSESSID cookie longer than 256 characters,
  • sh, bash, curl, wget or python processes started under the web server user (www-data) – the strongest evidence that an attack succeeded.

If you find signs of a successful attack, updating alone is not enough. Treat the server as compromised: check for new files and cron jobs, change database passwords and API keys and, in the worst case, rebuild the server from a backup.

The main lesson: old PHP is an open door

If you run current PHP, one update solves PHP2Shell. If you are on PHP 7.4 or 8.0, you now depend on whether your hosting or distribution picks up the patch – and for PHP 7.3 and older there is no fix at all. In practice, such applications are protected only by the temporary settings above, and the next critical flaw may not offer even that.

If you’re not sure which version your application runs on or whether it can handle the update, I’m happy to check it. In a PHP application audit I review the PHP version, server configuration and libraries with known vulnerabilities, and propose a path to a supported version. A quick audit typically takes 4–8 h, i.e. 10,000–20,000 CZK excl. VAT. If nobody looks after your application since the developer left, I can also take it over.

Sources: CERT-EU security advisory 2026-018, analyses by Datadog Security Labs, Google Cloud and watchTowr, PHP 8.5.12 release notes. Status as of 31 October 2026.

← All articles

More services

Automation and data processing

Price lists, enquiries, invoices and catalogues processed automatically and connected to your system. No more manual retyping. More about automation

PHP project takeover

Has your developer or agency left? I take over applications in Nette, Symfony or legacy PHP, stabilise them and keep developing them. How a takeover works

PHP application audit

Code, security, performance, database and the path to PHP 8.4/8.5. A written report with priorities and effort estimates. What the audit covers

Custom application development

B2B systems, admin panels, booking, invoicing and configurators in Nette, Symfony and React, integrated with your existing systems. How custom development works

Working on a similar project?

Write me a few sentences about your application. I will reply within one working day and suggest how to get started.