> ## Documentation Index
> Fetch the complete documentation index at: https://blog.onetsolutions.net/llms.txt
> Use this file to discover all available pages before exploring further.

# phpAfterShell (CVE-2026-126714): critical PHP session file RCE

> PHP flaw phpAfterShell (CVE-2026-126714): a half-rewritten session file can lead to remote code execution. Fixed versions, distro packages and mitigation.

*Published on November 25, 2026*

> [!WARNING]
>
> **CVE-2026-126714 "phpAfterShell" — PHP sessions, CVSS v4.0 9.2.** A partially rewritten PHP session file can lead to remote code execution. The affected session handler, `files`, is PHP's default. Fixed in **PHP 8.5.13, 8.4.28, 8.3.37 and 8.2.36**, released on November 19, 2026. Update PHP, or turn off `session.upload_progress` until the package lands.

## The bug in two sentences

The `files` session handler writes new session data over the existing file without clearing it first. If the write is interrupted, the file holds the start of the new session followed by the end of the old one: on the next `session_start()`, PHP unserializes that mix, and bytes from a plain string can turn into objects.

According to the PHP advisory, the attack needs three things:

* the attacker can influence session contents, for example through file upload progress tracking (`session.upload_progress`) or through long strings the application stores in the session;
* they can interrupt the write at the right moment, for example with a memory exhaustion that kills the process;
* a deserialization gadget chain is available.

The depthfirst researchers who found the flaw say their full chain does not depend on any application class: it relies on PHP's native classes and a memory corruption. According to them, a `multipart/form-data` request that reaches PHP with upload progress enabled is enough as an entry point. They published a demonstration video, with no exploit code.

The payoff for the attacker: code execution with the PHP worker's privileges. The flaw can also corrupt session data.

Affected versions:

* **PHP before 8.2.36**;
* **PHP 8.3.0 through 8.3.36**, fixed in **8.3.37**;
* **PHP 8.4.0 through 8.4.27**, fixed in **8.4.28**;
* **PHP 8.5.0 through 8.5.12**, fixed in **8.5.13**.

The PHP team says the faulty code goes back to PHP 4.1.0. The fix empties the session file before writing to it: an interrupted write can still lose the session, but no longer leaves part of the old one behind.

The PHP project scores the flaw **9.2** in CVSS 4.0 (`AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N`); NVD carries the same score. Red Hat rates it "Critical" with 8.1 in CVSS 3.1, Ubuntu medium priority. The full advisory is [GHSA-fm2m-fjf5-v3cp](https://github.com/php/php-src/security/advisories/GHSA-fm2m-fjf5-v3cp).

> [!NOTE]
>
> According to CISA's assessment, carried by NVD, no exploitation has been reported, but the attack is rated as automatable. The same PHP release fixes [PHP-FPM (CVE-2026-129289)](https://blog.onetsolutions.net/en/php-fpm-smuggling-cve-2026-129289.md) and [PHP-FPM (CVE-2026-129291)](https://blog.onetsolutions.net/en/php-fpm-epoll-cve-2026-129291.md): one update covers all three.

## Sizing your exposure

The question to ask: **are your PHP sessions stored in files?** That is the default, whichever way PHP runs (PHP-FPM, mod\_php, CGI).

| Profile | Exposure | Action |
| - | - | - |
| PHP site on the Internet, file sessions (`session.save_handler = files`), upload progress on | **Critical**: unauthenticated entry point | Update today; if you can't, turn off `session.upload_progress` |
| Application that stores long user-supplied strings in the session | **High**: the mitigation does not close this path | Update today |
| Sessions in a store that replaces each record in one go | Not affected by this write defect | Update anyway: the release fixes other flaws |
| Container that ships PHP | Same as the PHP configuration in the image | Rebuild on a fixed image |
| PHP used on the command line only, no web service | Not exposed to the described attack | Update at the next maintenance |

Check the session handler and upload progress in the loaded configuration:

```bash theme={null}
# PHP on the command line
php -i | grep -E 'session\.save_handler|session\.upload_progress\.enabled'

# PHP-FPM (adjust the version: php-fpm8.3 on Debian and Ubuntu, php-fpm on RHEL)
php-fpm8.3 -i | grep -E 'session\.save_handler|session\.upload_progress\.enabled'
```

A PHP-FPM pool or an Apache virtual host can override these values. Look for overrides:

```bash theme={null}
# PHP-FPM pools and Apache (Debian, Ubuntu then RHEL, AlmaLinux)
sudo grep -rnE 'session\.(save_handler|upload_progress)' /etc/php/*/fpm/pool.d/ /etc/php-fpm.d/ /etc/apache2/ /etc/httpd/ 2>/dev/null
```

`session.save_handler => files` means file sessions. `session.upload_progress.enabled => On` means the entry point described by the researchers is open.

> [!NOTE]
>
> The application can also pick its session store in its own code or configuration. If you are not sure which store is in use, treat it as file sessions and update.

## Updating PHP, distro by distro

The real fix is a PHP package update followed by a **restart** of PHP-FPM and Apache: processes already running keep the old code.

Take a [snapshot of your VPS](https://help.onetsolutions.net/vps/snapshot) first.

### Debian

| Version | Fixed package | Advisory |
| - | - | - |
| Debian 13 (trixie) | `php8.4` `8.4.28-1~deb13u1` | DSA-6641-1 |
| Debian 12 (bookworm) | `php8.2` `8.2.36-1~deb12u1` | DLA-4916-1 |

### Ubuntu

| Version | Fixed package |
| - | - |
| 26.10 | `php8.5` `8.5.9-0ubuntu2.2` |
| 26.04 LTS | `php8.5` `8.5.4-0ubuntu1.6` |
| 24.04 LTS | `php8.3` `8.3.6-0ubuntu0.24.04.14` |
| 22.04 LTS | `php8.1` `8.1.2-1ubuntu2.29` |
| 20.04 LTS | `php7.4` `7.4.3-4ubuntu2.29+esm6` (Ubuntu Pro) |

```bash theme={null}
# Debian, Ubuntu: install the PHP fixes, then restart PHP
sudo apt update
sudo apt install --only-upgrade 'php*'
sudo systemctl restart 'php*-fpm.service'
sudo systemctl restart apache2 2>/dev/null

# Check the installed version
dpkg -l 'php8*' | grep ^ii
```

> [!NOTE]
>
> Don't rely on the version printed by `php -v` alone. Debian and Ubuntu backport the fix: Ubuntu 24.04 still reports PHP 8.3.6 once patched. Only the full package version, compared with your distribution's advisory, is the reference.

### RHEL and AlmaLinux

Red Hat lists RHEL 7, 8, 9 and 10 as affected. As of November 24, 2026, its bulletin [RHSB-2026-020](https://access.redhat.com/security/vulnerabilities/RHSB-2026-020) says fixes are being expedited, with no erratum released yet: follow the [Red Hat CVE page](https://access.redhat.com/security/cve/cve-2026-126714). For AlmaLinux, watch [errata.almalinux.org](https://errata.almalinux.org).

```bash theme={null}
# Install the fix as soon as it ships, then restart PHP
sudo dnf upgrade 'php*'
sudo systemctl restart php-fpm
sudo systemctl restart httpd 2>/dev/null

# Check the installed version
rpm -q php-common
```

According to Red Hat, its updated packages for PHP 8.2 and later turn upload progress off by default. A setting explicitly enabled in your configuration still takes precedence.

Until the package lands, apply the mitigation below.

### Containers

Red Hat recommends rebuilding images based on RHEL or UBI as soon as their base image is updated. The same goes for any image that ships PHP: rebuild it on a fixed version, then redeploy.

## Turning off session.upload\_progress until you can update

The PHP team and Red Hat recommend turning off file upload progress tracking until the fixed package is installed. The setting must apply before the request is parsed: an `ini_set()` in the application comes too late. Put it in a `conf.d` file loaded at startup, then restart every PHP process.

```bash theme={null}
# Debian, Ubuntu: one file for each version and each SAPI
for dir in /etc/php/*/*/conf.d; do
  printf 'session.upload_progress.enabled = 0\n' | sudo tee "$dir/zz-phpaftershell.ini" >/dev/null
done
sudo systemctl restart 'php*-fpm.service'
sudo systemctl restart apache2 2>/dev/null
```

```bash theme={null}
# RHEL, AlmaLinux
printf 'session.upload_progress.enabled = 0\n' | sudo tee /etc/php.d/zz-phpaftershell.ini >/dev/null
sudo systemctl restart php-fpm
sudo systemctl restart httpd 2>/dev/null
```

To enforce it in a specific PHP-FPM pool, add this to its configuration (for example `/etc/php/8.3/fpm/pool.d/www.conf`):

```ini theme={null}
php_admin_flag[session.upload_progress.enabled] = off
```

> [!NOTE]
>
> This mitigation closes the file upload entry point. It does not protect an application that itself stores attacker-supplied data in the session: limit that data and update. A session store that replaces each record in one go is not hit by this write defect.

## Checking the mitigation

```bash theme={null}
# The package version must match your distribution's advisory
dpkg -l 'php8*' | grep ^ii         # Debian, Ubuntu
rpm -q php-common                  # RHEL, AlmaLinux

# PHP-FPM must have restarted after the package update
systemctl show -p ActiveEnterTimestamp 'php*-fpm.service'

# Effective upload progress value (adjust the php-fpm version)
php -i | grep 'session\.upload_progress\.enabled'
php-fpm8.3 -i | grep 'session\.upload_progress\.enabled'
```

If you applied the mitigation, the expected value is `session.upload_progress.enabled => Off`. Red Hat reminds you to check every PHP-FPM pool, every virtual host and every application-level override: changing only the command-line PHP configuration is not enough.

## Re-enabling upload progress after the update

The PHP advisory describes this as a temporary measure. Once PHP is fixed and restarted, you can bring upload progress back if an application uses it to show how far an upload has gone:

```bash theme={null}
# Debian, Ubuntu
sudo rm -f /etc/php/*/*/conf.d/zz-phpaftershell.ini
sudo systemctl restart 'php*-fpm.service'
sudo systemctl restart apache2 2>/dev/null

# RHEL, AlmaLinux
sudo rm -f /etc/php.d/zz-phpaftershell.ini
sudo systemctl restart php-fpm
sudo systemctl restart httpd 2>/dev/null
```

According to Red Hat, the setting also protects against CVE-2026-115560, and it covers [php2shell (CVE-2026-109619)](https://blog.onetsolutions.net/en/php2shell-cve-2026-109618.md) too. If no application uses upload progress, there is no need to turn it back on.

## What next?

Turning off `session.upload_progress` is only a stopgap: the target remains your distribution's fixed PHP package. The same update also fixes [the PHP-FPM flaw CVE-2026-129289](https://blog.onetsolutions.net/en/php-fpm-smuggling-cve-2026-129289.md). Turn on [automatic security updates](https://blog.onetsolutions.net/en/automatic-security-updates-linux-vps.md) to get the next fixes without waiting. For any technical question, open a ticket from your [OnetSolutions customer area](https://help.onetsolutions.net/console/support).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.