Under attack right now? hello@incursor.io
BlogPentest

PHP2Shell, CVE-2026-109618 and CVE-2026-109619: two flaws in PHP itself

On 21 October PHP shipped emergency releases 8.5.12, 8.4.27, 8.3.36 and 8.2.35 for two CVEs rated 9.2. Both are in the PHP engine, so WordPress, its plugins and your own code are not the cause, and a plain Hello World on an affected version is vulnerable. Details leaked the day before the release and exploitation has already started. Below is how the bugs work and what I would do today.

Gerard Capdevila Oct 2026 · 16 min read · PHP
KEY TAKEAWAYS
CVE-2026-109618 and CVE-2026-109619, CVSS v4 9.2: unauthenticated remote code execution, plus a Heartbleed-style memory leak.
Every version since PHP 5.4 is affected by at least one of the bugs. Fixed in 8.5.12, 8.4.27, 8.3.36 and 8.2.35, with nothing planned for PHP 5 and 7.
The confirmed path goes through Session Upload Progress, which is on by default. The application does not need to call session_start().
No php.ini setting closes every path. Update, restart every worker, then rotate any secret that may have leaked.

1. Timeline

Wiz Research found the first bug on 19 August with help from AI models and reported it to PHP on the 24th. Coordinated disclosure was set for 21 October at 14:00 UTC. On the 20th the details leaked, together with a proof-of-concept tool called PHP2Shell. watchTowr confirmed soon after that it had reproduced both flaws, and it has since seen real exploitation attempts. The UK NCSC advises taking offline any server that cannot be updated immediately.

2. Root cause: global state that survives a failed request

The four bugs described share one root cause. When a request dies on a fatal error, typically memory exhaustion, PHP frees the request heap but does not reset some global pointers. The worker keeps running, and the next request it handles reuses those pointers, which now point to memory the attacker may have filled. This is a use-after-free across two requests, which is why the quality of the application code makes no difference. The excerpt below, from php-src 8.4.26, shows the path: zend_mm_safe_error() raises the fatal error, then zend_bailout() calls longjmp() and never returns.

/* Zend/zend_alloc.c: called when an allocation exceeds memory_limit */
/* (ZEND_DEBUG parameters omitted) */
static ZEND_COLD ZEND_NORETURN void zend_mm_safe_error(zend_mm_heap *heap,
	const char *format, size_t limit, size_t size)
{
	heap->overflow = 1;
	zend_try {
		zend_error_noreturn(E_ERROR, format, limit, size);
		/* "Allowed memory size of %zu bytes exhausted (tried to allocate %zu bytes)" */
	} zend_catch {
	}  zend_end_try();
	heap->overflow = 0;
	zend_bailout();                          /* never returns */
	exit(1);
}

/* Zend/zend.c */
ZEND_API ZEND_COLD ZEND_NORETURN void _zend_bailout(const char *filename, uint32_t lineno)
{
	...
	CG(unclean_shutdown) = 1;
	...
	EG(current_execute_data) = NULL;
	LONGJMP(*EG(bailout), FAILURE);          /* jumps back to the last zend_try / php_request_startup frame */
}

3. Memory leak through the session cookie

PHP parses multipart requests very early, before normal module initialisation, and upload progress tracking can already create a session ID at that stage. If the request then crashes on low memory, the PS(id) pointer stays set and points to freed memory. The next multipart request on the same worker goes through the upload cleanup code, which treats that pointer as a valid string and returns its content in the PHPSESSID cookie. The attacker receives a chunk of worker memory that can hold passwords, tokens or API keys from other requests, without code execution and without an account. PS(id) is allocated on the request heap during the multipart callback and only reset in php_rshutdown_session_globals(), which a bailout skips.

/* main/rfc1867.c: multipart parsing, before the script runs */
if (php_rfc1867_callback != NULL) {
	...
	if (php_rfc1867_callback(MULTIPART_EVENT_START, &event_start, &event_extra_data) == FAILURE) {

/* ext/session/session.c: php_session_rfc1867_callback() */
case MULTIPART_EVENT_FILE_START: {
	...
	php_rinit_session(0);
	PS(id) = zend_string_init(Z_STRVAL(progress->sid), Z_STRLEN(progress->sid), 0);
	/* request-heap allocation (persistent = 0) */

case MULTIPART_EVENT_END: {
	...
	php_rshutdown_session_globals();   /* the only place PS(id) is reset */

/* php_rshutdown_session_globals() */
if (PS(id)) {
	zend_string_release_ex(PS(id), 0);
	PS(id) = NULL;
}

/* php_session_send_cookie() */
/* URL encode id because it might be user supplied */
e_id = php_url_encode(ZSTR_VAL(PS(id)), ZSTR_LEN(PS(id)));   /* reads len and val through PS(id) */
smart_str_appendl(&ncookie, "Set-Cookie: ", sizeof("Set-Cookie: ")-1);

4. Three paths to code execution

The first path uses the session unserializer, which runs during upload tracking and leaves its global state published after the crash. Combined with the memory leak to locate addresses, it gave Wiz unauthenticated code execution on WordPress, Drupal and Joomla in their latest Docker images. The second path uses EG(last_fatal_error_backtrace), where PHP keeps the backtrace of the last fatal error. After a memory crash that pointer targets the previous request’s memory. Wiz demonstrated it on Drupal. The third path goes through OPcache. An allocation that fails at the wrong moment leaves the shared memory indexes out of sync between workers, which produces a type confusion. Wiz demonstrated it on WordPress.

5. Two CVEs, two bug families

CVE-2026-109618, nicknamed “rawkey”, targets the Zend Engine hash table. The attacker sends an application/x-www-form-urlencoded POST of several megabytes with a huge field name. PHP runs out of memory while filling $_POST, in the middle of inserting a key, and the bucket is left half initialised. End-of-request cleanup then treats it as valid. CVE-2026-109619 covers the stale global state cases described above: the session deserialiser, the last fatal error backtrace and OPcache. Both families have the same trigger, a memory error at the wrong moment followed by code that trusts whatever state is left. In _zend_hash_str_add_or_update_i(), the counters are incremented before the key string is allocated, which is where the bailout lands.

/* Zend/zend_hash.c: _zend_hash_str_add_or_update_i() */
	ZEND_HASH_IF_FULL_DO_RESIZE(ht);

add_to_hash:
	idx = ht->nNumUsed++;                 /* the bucket is counted as used here */
	ht->nNumOfElements++;
	p = ht->arData + idx;
	p->key = key = zend_string_init(str, len, GC_FLAGS(ht) & IS_ARRAY_PERSISTENT);
	                                      /* emalloc(len): with a field name of several MB, memory_limit is hit and zend_bailout() runs */
	p->h = ZSTR_H(key) = h;
	...
	ZVAL_COPY_VALUE(&p->val, pData);      /* never reached: p->key and p->val keep whatever was in memory */
	nIndex = h | ht->nTableMask;
	Z_NEXT(p->val) = HT_HASH(ht, nIndex);
	HT_HASH(ht, nIndex) = HT_IDX_TO_HASH(idx);

6. How PHP handles a fatal error: longjmp and stale pointers

When the Zend allocator runs out of memory, PHP does not unwind the stack. It jumps straight to the error handler with longjmp(), and whatever operation was running stops halfway through. For CVE-2026-109618 the interrupted function is _zend_hash_str_add_or_update_i(), which inserts a key into a hash table: the bucket is reserved but its key is not yet written. For CVE-2026-109619 the affected components publish global state before finishing their work: session upload progress and fatal_error_backtraces. The CWE list matches that description: CWE 416 (use after free), CWE 755 (improper handling of exceptional conditions), CWE 824 (access of uninitialized pointer) and CWE 1419 (incorrect initialization of resource). In each case the code assumes an error will never interrupt it mid-operation. A PHP core developer noticed this out-of-memory behaviour during an audit in 2024. With no agreement on the fix and no known exploit, the issue stayed in the backlog until Calif, OpenAI and Wiz, helped by AI models, built a full exploit chain. zend_try is a setjmp() wrapper: the code between the jump and the landing frame does not unwind.

/* Zend/zend.h (ZEND_ASSERT lines omitted) */
#define zend_try                                         \
	{                                                    \
		JMP_BUF *__orig_bailout = EG(bailout);          \
		JMP_BUF __bailout;                               \
		EG(bailout) = &__bailout;                        \
		if (SETJMP(__bailout)==0) {
#define zend_catch                                       \
		} else {                                        \
			EG(bailout) = __orig_bailout;
#define zend_end_try()                                   \
		}                                                \
		EG(bailout) = __orig_bailout;                    \
	}

/* What happens on bailout
 *   SETJMP()  returns 0 when the frame is set up
 *   LONGJMP() returns to that frame with FAILURE, skipping every function in between
 *   no destructor or cleanup code of the interrupted functions runs */

7. Attack sequence

The attacker first identifies targets. An X-Powered-By header, a PHPSESSID cookie or a .php URL is enough, and no account or upload form is required: any URL served by PHP works. Next comes the memory leak. A few multipart requests crash on purpose, and the PHPSESSID cookie in the responses returns memory addresses that defeat ASLR, and sometimes passwords or tokens from other visitors. The exploit is then fitted to the binary. Public PoCs include the offsets between functions for common builds such as Debian Bookworm, Ubuntu Noble and Ubuntu Jammy, so on an official Docker image the step is close to copy and paste. According to Datadog, the rawkey exploit reaches code execution in three stages: reach the interrupted insertion, fill the unfinished bucket with controlled data, then turn request cleanup into a system() call. On mod_php all of this happens before the application code starts. The attacker then sets up persistence: a webshell, a read of wp-config.php or the .env file, database credentials and, on an e-commerce site, a skimmer in the checkout. Sansec reports confirmed RCE on Magento, Shopware and WooCommerce. Amazon’s MadPot honeypot network saw an attempt on 17 October, four days before disclosure, and Cloudflare saw attacks on the 21st at 07:43 UTC, before the patch was out.

8. Who is exposed

Every setup that serves web requests with PHP: PHP-FPM, Apache mod_php, php-cgi, FrankenPHP and LiteSpeed. mod_php is the worst case because the attack can succeed before the application code runs. On shared hosting the provider applies the patch, so ask yours when it is done. PHP 7.4, 8.0 and 8.1 have no official fixed release, which leaves a distribution backport or a migration. For anything older, I would take the servers off the Internet.

9. Patching and follow-up

Check the version that actually serves requests, not the one in the package list. php -v on the command line says nothing about the PHP behind your pages, so check every SAPI, every FPM pool, every Docker image and every base image. Update to 8.5.12, 8.4.27, 8.3.36 or 8.2.35, then restart every worker, because a partial reload can leave old code running. For containers, rebuild the image and redeploy instead of patching a running container. On 7.4, 8.0 or 8.1 the options are the backports published in the PHP source or your distribution’s patched package, and otherwise a migration. If you cannot patch immediately, you can reduce the risk without removing it. Datadog recommends enforcing memory_limit=-1 at the administrator level, together with request size limits on the reverse proxy and a memory limit on the container. Also cap the size of decoded request bodies, including those sent without a Content-Length. Setting session.upload_progress.enabled = 0, plus fatal_error_backtraces = 0 on PHP 8.5, removes the known paths. The published WAF rules buy a few hours. After patching, deal with the memory leak. If the server was exposed after 17 October, assume that anything handled by its workers may have been read: rotate API keys, database passwords and session secrets, and invalidate active sessions. On mod_php the TLS private key lives in the same process as Apache, so renew the certificate as well. The commands and pool settings below cover the version check and the interim hardening.

# 1. Version of the PHP that actually serves requests
php-fpm8.3 -v
ps -eo pid,user,args | grep -E 'php-fpm|httpd|apache2|frankenphp' | grep -v grep
docker run --rm --entrypoint php <image> -v

# 2. Interim hardening (Datadog / PHP guidance), set in the pool, not in .user.ini
; /etc/php/8.3/fpm/pool.d/www.conf
php_admin_value[memory_limit] = -1
php_admin_value[post_max_size] = 8M
php_admin_flag[session.upload_progress.enabled] = off
; PHP 8.5 only
php_admin_flag[fatal_error_backtraces] = off

# 3. Restart every worker
systemctl restart php8.3-fpm

10. Detecting attempts

Exploitation happens below the application, so application logs show almost nothing. On the server I check for unusual multipart requests followed by memory limit errors or bursts of 500 responses, for huge or malformed PHPSESSID cookies in responses, and for PHP workers restarting without reason. As after any RCE, then look for webshells, new cron jobs and accounts created by the user that runs PHP. These commands are a starting point on a Debian or Ubuntu server with nginx and PHP-FPM; adjust the paths to your setup.

# Memory limit errors
grep -E "Allowed memory size of [0-9]+ bytes exhausted" /var/log/php*-fpm.log

# IPs sending POSTs that end in 500
awk '$6 ~ /POST/ && $9 == 500' /var/log/nginx/access.log | awk '{print $1}' | sort | uniq -c | sort -rn | head

# Workers dying more often than traffic explains
journalctl -u 'php*-fpm' --since "2026-10-17" | grep -E "exited on signal|child [0-9]+ exited"

# Webshells and persistence
find /var/www -name '*.php' -mtime -35 -ls
crontab -l -u www-data

11. CVE-2026-115560

Two days after the patches, PHP published an informational advisory for a third flaw, CVE-2026-115560. It covers a narrow case: an application that switches session.serialize_handler to php at runtime, with session upload progress enabled. There is no public proof of concept and no known exploitation, and PHP rates the risk as unlikely. It should not delay the main update, but search your code for ini_set('session.serialize_handler' and remove that runtime setting if you find it. More advisories are likely, since researchers are now looking at the same bug class. The search below finds the runtime setting.

# Runtime change of the serializer (CVE-2026-115560 precondition)
grep -rnE "ini_set\(\s*['\"]session\.serialize_handler" --include='*.php' .

# Upload progress status on the CLI build (check FPM separately)
php -r 'var_dump(ini_get("session.upload_progress.enabled"));'

12. Why it took ten years

The faulty code had been in PHP for more than ten years. What was missing was the time to turn the bugs into an exploit that works reliably across versions. According to Wiz, AI models let a single researcher do in a week what would have taken a team months, and attackers have access to the same tools. A flaw considered too complex to exploit can no longer stay in the backlog on that basis.

DO THIS TODAY
→Rotate API keys, passwords and session secrets on any server exposed since 17 October.
→List your PHP servers, starting with Internet-facing ones and those on mod_php.
→Keep a copy of logs and configuration before changing anything.
→Move to 8.5.12, 8.4.27, 8.3.36 or 8.2.35 depending on your branch, then restart every worker.
→Rebuild your Docker images instead of patching containers in place.
→Look for webshells, cron jobs and unknown accounts on machines exposed since 20 October.
→Take any server you cannot patch today off the Internet.

FAQ

My WordPress is up to date. Am I safe?

No. The flaw is in PHP, so an up-to-date WordPress running on an unpatched PHP is still vulnerable.

Why 9.2 and not 10, as the leak claimed?

The 10.0 came from whoever leaked the details. PHP ran its own CVSS v4.0 scoring and settled on 9.2 for both CVEs, while watchTowr still rates it 10. Either way it is critical and needs the patch.

Can I disable session.upload_progress for now?

That removes one known path and leaves the others. PHP and watchTowr both state that no php.ini change is enough, so apply the update.

Does my WAF protect me?

Cloudflare, Fastly, Akamai and others have shipped rules. They buy a few hours and do not replace the patch.

Can you check my servers?

Yes. We check the version actually exposed, the configuration and any signs of exploitation, then tell you what to fix first.

Want to know if your PHP servers are affected?

Test us. An expert hacker replies within one business day.
Incursor
© 2026 Incursor Security · Paris · Barcelona · Amsterdam · EU based
{{ rIncidentQ }} hello@incursor.io
Incursor {{ menuLabel }}
{{ navServices }} {{ navEngagements }} {{ navMethod }} {{ navTeam }} {{ navBlog }}
{{ navContact }}
{{ navBlog }}{{ arCat }}

{{ arT }}

{{ arLede }}

{{ arAuthor }} {{ arMeta }}
{{ arTldrT }}
{{ b }}

{{ sec.n }}. {{ sec.h }}

{{ sec.p }}

{{ sec.code }}
{{ li.t }} {{ li.t }}
{{ heatLowL }}
{{ heatMediumL }}
{{ heatHighL }}
{{ heatCriticalL }}
{{ arFlagsT }}
{{ arFlagMark }}{{ f }}

{{ arFaqT }}

{{ q.q }}

{{ q.a }}

{{ arSvcT }} {{ sv.t }}

{{ arCta }}

{{ rHmEndBtn }} {{ rHmEndNote }}
Incursor
© 2026 Incursor Security · {{ cities }}