php2shell: update PHP, and switch off session upload progress
Today (21 October 2026) the PHP project published two critical advisories, collectively nicknamed php2shell: CVE-2026-109618 and CVE-2026-109619, both rated CVSS 4.0 9.2. Details leaked a day before the coordinated release, and exploitation attempts are already being reported.
The bugs are in the PHP runtime itself, not in Laravel, Symfony or your code. So the fix is in the runtime too.
1. Update PHP first
The fixed releases are 8.2.35, 8.3.36, 8.4.27 and 8.5.12. Updating is the only complete mitigation; everything below only reduces exposure until you can.
- PHP 7.4, 8.0 and 8.1 only get limited source backports, so take your distribution's patched build or upgrade.
- Distribution packages may keep the old version number, so check your vendor's advisory, not just
php -v. - Restart every PHP worker (FPM pools, Apache), or the old binary keeps running.
2. What actually goes wrong
When PHP runs out of memory or hits a fatal error, it abandons the request by jumping straight out of
whatever it was doing (a longjmp() "bailout"). If that happens after some state has been set up but before
it's reset, the worker is left holding pointers into memory that is freed when the request ends.
PHP workers are reused. The next request handled by the same worker can then read that stale state as if it were valid. That's a use-after-free, which the advisories show leading to memory disclosure (cookies, tokens, API keys) and remote code execution with the worker's privileges.
The timing is the whole trick:
- Request A sends a multipart body. While PHP is still parsing it, session upload progress writes session state into the worker's globals.
- The attacker makes request A run out of memory (crafted multipart input is enough). The bailout skips the reset.
- Request A ends, and its memory is freed. The globals now point at freed memory.
- Request B lands on the same worker and reads those globals before normal initialisation.
This takes luck and repetition: attack complexity is rated high, and the second request has to hit the same
worker. But it needs no authentication and no particular endpoint. Any PHP URL that accepts a POST will do,
even one that only returns OK.
3. Switch off session upload progress
session.upload_progress.enabled = Off
What it does
Session upload progress lets PHP report how far a
large upload has got. If a multipart POST contains a field named PHP_SESSION_UPLOAD_PROGRESS, PHP writes
progress data (bytes received, file names, a "done" flag) into the native $_SESSION while it's still
receiving the body, before your script starts. A second request can then poll that session for a progress bar.
It's on by default, and it runs even if your application never calls session_start().
Why your Laravel app doesn't use it
- Laravel doesn't use native PHP sessions. Its session (
laravel_session) is a separate system with its own drivers (file, database, Redis and so on). Progress data written into$_SESSIONlands in a store your app never reads. - Upload progress lives in the browser now.
fetch/XHR upload events, Livewire'swire:modelfile uploads and Inertia's upload progress all measure progress client-side. None of them poll the server. - Behind a proxy or a serverless platform the body is often buffered anyway. Nginx's default request buffering, a load balancer, or API Gateway on AWS Lambda hand PHP the complete body at once, so there's nothing to report progress on.
Why disabling it helps
It's work PHP does on every multipart request, before routing, middleware or authentication. That makes it the perfect remote trigger. The Imperva analysis found that switching it off removes the trigger for three of the five demonstrated exploitation techniques, and it's the session workaround named in PHP's own advisory. For a Laravel app it costs nothing.
It must be set where PHP reads it before parsing the request: php.ini, the FPM pool
(php_admin_flag[session.upload_progress.enabled] = off) or the server config. ini_set() in your app and FPM
.user.ini files are too late. Restart the workers, then check both the CLI and the web side, because they often
read different ini files:
php -i | grep session.upload_progress.enabled # CLI
php-fpm8.4 -tt 2>&1 | grep upload_progress # FPM: dumps the parsed pool config
Never check it by publishing a phpinfo() page. If you can't run FPM's test mode, log
ini_get('session.upload_progress.enabled') once from a request and remove the line afterwards.
4. The other changes
None of these is a fix. Each one removes a trigger or makes one harder.
Disable fatal error backtraces (PHP 8.5)
fatal_error_backtraces = Off
PHP 8.5 attaches a backtrace to fatal errors, and that path was used for one of the demonstrated RCEs. According to PHP's advisory, turning it off takes away the confirmed RCE trigger on 8.5. You lose a debugging aid in logs, which an error tracker usually covers.
Make out-of-memory harder to trigger with request input
post_max_size = 8M ; 32M if you accept uploads
upload_max_filesize = 6M ; keep it below post_max_size
max_file_uploads = 5
max_input_nesting_level = 32
The OOM in step 2 is reached through oversized or deeply structured input: huge bodies, thousands of parts,
endless headers per part, deeply nested a[b][c][d]… fields. Tight limits shrink that surface.
Enforce the same limits in front of PHP too:
- Cap body size in nginx or the load balancer, including chunked requests without a
Content-Length. - Limit header counts at the proxy.
- If an app never takes uploads, reject
multipart/form-dataat the proxy. Then none of the multipart paths are reachable.
About memory_limit = -1
The CVE-2026-109618 advisory calls an unlimited memory_limit the primary configuration mitigation, because no
limit means no PHP-level OOM bailout. It's a real trade-off: one runaway request can now take the whole box.
- If you use it, enforce it administratively (
php_admin_value), so the app can't restore a limit. - Put a container or cgroup memory limit around the worker instead.
- Don't use
RLIMIT_ASorRLIMIT_DATA. They make allocations fail, which is exactly the path being exploited.
Optional: one request per worker
pm.max_requests = 1
The exploit needs a second request on the same worker. Recycling workers after every request removes that, at a noticeable performance cost. It's an emergency measure, not a long-term setting.
A WAF helps, but don't rely on it
Cloudflare and others shipped rules before disclosure, and they're already seeing bypass attempts. Treat a WAF as a speed bump while you patch, not as the fix.
5. Checklist
All the php.ini changes in one file:
; php2shell (CVE-2026-109618, CVE-2026-109619) hardening.
; Updating PHP is the only complete fix; these settings reduce exposure.
; Load them where PHP reads them before parsing a request (php.ini, conf.d or
; the FPM pool), never from ini_set() or .user.ini, then restart every worker.
; Removes the remote trigger behind most of the demonstrated techniques.
; Laravel doesn't use native PHP sessions, so nothing depends on it.
session.upload_progress.enabled = Off
; PHP 8.5: the backtrace path was a confirmed RCE producer.
fatal_error_backtraces = Off
; Make out-of-memory harder to reach with crafted request input.
post_max_size = 8M ; 32M if the app accepts uploads
upload_max_filesize = 6M ; keep below post_max_size
max_file_uploads = 5
max_input_nesting_level = 32
- PHP updated to 8.2.35 / 8.3.36 / 8.4.27 / 8.5.12 (or a vendor build with the backport), workers restarted
-
session.upload_progress.enabled = Offin php.ini or the FPM pool, confirmed on the web SAPI -
fatal_error_backtraces = Offon PHP 8.5 - Conservative
post_max_size,upload_max_filesize,max_file_uploads,max_input_nesting_level - Body and header limits at the proxy; multipart blocked where it isn't used
- Logs checked for crashed workers or odd multipart traffic since mid-October
Update, 8 November 2026
- A related flaw. Two days after php2shell, PHP announced
CVE-2026-115560, another
upload-progress code execution path. It also affects the patched releases and is being fixed in the regular
release cycle. It needs an unusual setup (switching the session serializer at runtime), and the mitigation is
the same:
session.upload_progress.enabled = Off. If you followed step 3, there's nothing more to do. - This site's stack (Laravel on AWS Lambda with Bref) already runs PHP 8.5.12, and the Bref runtime ships with
upload progress switched off.
fatal_error_backtracesis still on there, which is PHP 8.5's default. Check yours rather than assuming.
Sources
- PHP security advisory GHSA-w8hw-w9fx-j79w: RCE via OOM corruption (CVE-2026-109618)
- PHP security advisory GHSA-6wmf-4rv5-p3rp: RCE via stale global state (CVE-2026-109619)
- Qualys: PHP2Shell: Find, Mitigate, and Patch Now
- Imperva: PHP2Shell: When PHP Runs Out of Memory at the Wrong Moment
- PHP manual: Session upload progress