# phpAfterShell (CVE-2026-126714): PHP Files Session Handler Partial-Overwrite Flaw Bypasses PHP2Shell Fix, Enabling Remote Code Execution

> phpAfterShell (CVE-2026-126714) is a CVSS v4.0 9.2 flaw in PHP's default files session save handler: an interrupted in-place session write leaves a mix of new and old data that PHP later deserializes as objects, which can lead to remote code execution. It was disclosed on 2026-11-19 by depthfirst and works on servers patched for the October PHP2Shell flaws. Sources describe research demonstrations only and report no in-the-wild exploitation.

- **Published:** 2026-11-19T17:03:44Z
- **Last reviewed:** 2026-11-20T13:56:37.657Z
- **Canonical:** https://intel.threadlinqs.com/threat/TL-2026-6478
- **ID:** TL-2026-6478
- **Severity:** CRITICAL (CVSS 9.2)
- **Category:** VULNERABILITY
- **Status:** TRACKING
- **Detections:** 9 (1 shown free below) · **IOCs:** 10
- **CVEs:** CVE-2026-126714, CVE-2026-115560

## Description

phpAfterShell is a vulnerability in ext/session in PHP's default `files` session save handler (CVE-2026-126714, CWE-367 and CWE-662). The handler writes updated session data over the existing session file in place, using pwrite() followed by ftruncate(), without clearing the file first. These operations are not atomic. If the PHP worker is interrupted partway through, the file can contain a prefix of the new session followed by the tail of the old one. The mixed file can still parse, but with a different meaning: length fields in the new prefix can make leftover bytes of an ordinary string parse as new session keys and serialized objects.

The most direct trigger is session upload progress (`session.upload_progress.enabled`). During RFC 1867 multipart parsing, PHP's upload-progress callback can open, read, update and rewrite the session file before the target script runs. A single unauthenticated multipart/form-data request is therefore enough to reach the session file, and an application login check does not block it. depthfirst describes two variants. In Variant A the worker is killed during pwrite(), usually by a memory-cgroup OOM kill, and the truncate happens before the write. In Variant B the worker dies between pwrite() and ftruncate(), and the truncate happens after the write. The GitHub advisory (GHSA-fm2m-fjf5-v3cp) lists further triggers: large user-controlled strings stored in sessions and, in threaded builds, a memory-limit failure in another thread that interrupts the write.

The next request that calls session_start() deserializes the promoted objects. The October PHP2Shell patches (CVE-2026-109618 and CVE-2026-109619) made the upload-progress callback carry objects as __PHP_Incomplete_Class. That restriction ends when RFC 1867 processing finishes, and the serialized data still reaches the file, so it does not stop this attack. depthfirst reports chaining the injected object into a memory-corruption bug in a PHP-native class to get code execution in the Apache worker process. The native-class decoder and heap layout were withheld pending coordinated disclosure. The advisory also notes that a suitable application gadget chain can give code execution. Code runs with the privileges of the PHP worker, which can expose credentials, application files and customer records.

The public proof from depthfirst uses a harmless stdClass object to show the splice (it creates $_SESSION['evil']), and a full-chain HTTP demonstration video is linked. The source article reports no in-the-wild exploitation and lists no IOCs or threat actors. Sessions stored in Redis or a database are reportedly not affected by this specific flaw. The fix (php-src commit c2b02f24dff, 'ext/session: Truncate session file after successful write') changes the truncate ordering. The GHSA advisory says the shipped fix truncates the file to zero before writing and aborts if truncation fails. Interrupted writes may still lose data, but the old suffix is no longer retained. Fixed releases are PHP 8.2.36, 8.3.37, 8.4.28 and 8.5.13. Official PHP 7.4, 8.0 and 8.1 minimal-backport branches are listed as not vulnerable by depthfirst, because the upload-progress callback returns without opening the session. The source article describes PHP 8.0 and 8.1 as out of support. Downstream distribution packages may carry fixes without changing PHP_VERSION.

The PHP2Shell flaws (CVE-2026-109618, memory corruption on OOM, and CVE-2026-109619, a use-after-free in upload progress) were patched on 2026-10-21 and added to CISA KEV on 2026-10-26 after exploitation was confirmed. phpAfterShell itself is not on KEV. A separate, distinct session-related PHP issue, CVE-2026-115560, was disclosed on 2026-10-23. Sources do not say whether it is related to phpAfterShell.

## MITRE ATT&CK

- T1190 Exploit Public-Facing Application
- T1059 Command and Scripting Interpreter
- T1499.004 Endpoint Denial of Service: Application or System Exploitation
- T1565.001 Data Manipulation: Stored Data Manipulation
- T1552.001 Unsecured Credentials: Credentials In Files
- T1005 Data from Local System
- T1059.004 Command and Scripting Interpreter: Unix Shell
- T1105 Ingress Tool Transfer

## Free detection (Splunk SPL, Microsoft KQL, Sigma)

**phpAfterShell Upload-Progress Multipart Burst — Exploitation (SPL)** (`TL-2026-6478-SPL-001`)

Detects the unauthenticated request shape used to reach the PHP files session handler partial-overwrite flaw phpAfterShell (CVE-2026-126714, TL-2026-6478): multipart/form-data POSTs carrying the PHP_SESSION_UPLOAD_PROGRESS field, or a one-minute burst of multipart POSTs from one source that coincides with HTTP 5xx responses (worker killed mid-write by OOM or memory_limit, Variant A/B). The marker is only visible where WAF/ModSecurity audit logs capture request bodies; the burst-plus-5xx branch works on plain web logs.

- **Languages:** Splunk SPL, Microsoft KQL, Sigma
- **ATT&CK:** T1190, T1499.004, T1565.001
- **Data sources:** apache:access, nginx:plus:kv, modsec:audit, waf_logs
- **Severity:** critical
- **Confidence:** high

### Splunk SPL

```spl
index=web (sourcetype="apache:access" OR sourcetype="nginx:plus:kv" OR sourcetype="modsec:audit") earliest=-24h http_method=POST (http_content_type="multipart/form-data*" OR "PHP_SESSION_UPLOAD_PROGRESS")
| eval progress_marker=if(match(_raw,"PHP_SESSION_UPLOAD_PROGRESS"),1,0), server_error=if(tonumber(status)>=500,1,0)
| bin _time span=1m
| stats count AS multipart_posts sum(progress_marker) AS progress_marker_hits sum(server_error) AS server_errors dc(uri_path) AS distinct_uris values(uri_path) AS uris values(http_user_agent) AS user_agents by _time, src, dest
| where progress_marker_hits>0 OR (multipart_posts>=20 AND server_errors>=3)
| table _time src dest multipart_posts progress_marker_hits server_errors distinct_uris uris user_agents
```

### Microsoft KQL

```kql
CommonSecurityLog
| where TimeGenerated > ago(24h)
| where RequestMethod =~ 'POST'
| where AdditionalExtensions has 'PHP_SESSION_UPLOAD_PROGRESS' or Message has 'PHP_SESSION_UPLOAD_PROGRESS' or AdditionalExtensions has 'multipart/form-data'
| extend ProgressMarker = iff(AdditionalExtensions has 'PHP_SESSION_UPLOAD_PROGRESS' or Message has 'PHP_SESSION_UPLOAD_PROGRESS', 1, 0)
| summarize MultipartPosts = count(), ProgressMarkerHits = sum(ProgressMarker), DistinctUris = dcount(RequestURL), Uris = make_set(RequestURL, 10), UserAgents = make_set(RequestClientApplication, 5) by bin(TimeGenerated, 1m), SourceIP, DestinationIP
| where ProgressMarkerHits > 0 or MultipartPosts >= 20
| project TimeGenerated, SourceIP, DestinationIP, MultipartPosts, ProgressMarkerHits, DistinctUris, Uris, UserAgents
```

### Sigma

```yaml
title: phpAfterShell PHP_SESSION_UPLOAD_PROGRESS Multipart POST (CVE-2026-126714)
id: 6b1f3c2e-8a47-4d1b-9c55-2f0a7e4d1a01
status: experimental
description: Detects web or WAF log records for POST requests carrying the PHP_SESSION_UPLOAD_PROGRESS field, the unauthenticated route to the PHP files session handler partial-overwrite flaw phpAfterShell (CVE-2026-126714, TL-2026-6478).
references:
    - https://depthfirst.com/research/phpaftershell
    - https://github.com/php/php-src/security/advisories/GHSA-fm2m-fjf5-v3cp
author: Threadlinqs Team
date: 2026/11/19
tags:
    - attack.initial-access
    - attack.t1190
    - attack.impact
    - attack.t1499.004
    - cve.2026.126714
logsource:
    category: webserver
detection:
    keywords:
        - 'PHP_SESSION_UPLOAD_PROGRESS'
    selection_method:
        cs-method: 'POST'
    condition: keywords and selection_method
falsepositives:
    - Applications that legitimately use PHP session upload progress tracking
    - Vulnerability scanners and authorized penetration tests
level: high
```

**Known false positives:**

- Applications that legitimately enable session.upload_progress and send PHP_SESSION_UPLOAD_PROGRESS with large file uploads
- Bulk file-upload clients or backup tools producing bursts of multipart POSTs, some ending in 5xx under load
- Authorized vulnerability scanners and penetration tests

**Tuning notes:** Marker matching needs request-body logging (ModSecurity audit, WAF). Without it only the burst-plus-5xx branch fires; tune multipart_posts>=20 and server_errors>=3 to your upload baseline. Allow-list known upload endpoints and trusted source ranges. Correlate hits with kernel OOM-kill events on the same host in the same minute.

### 8 more detection rules (Splunk SPL, Microsoft KQL, Sigma), unlock with TL Creds

- phpAfterShell Upload-Progress Multipart Burst — Exploitation (KQL) (locked: unlock with TL Creds)
- phpAfterShell PHP Worker Spawning Shell or Downloader — Post-Exploitation (KQL) (locked: unlock with TL Creds)
- phpAfterShell Related Community Infrastructure Contact — C2 / Ingress Transfer (KQL) (locked: unlock with TL Creds)
- phpAfterShell Upload-Progress Multipart POST — Exploitation (Sigma) (locked: unlock with TL Creds)
- phpAfterShell PHP Worker Spawning Shell or Downloader — Post-Exploitation (Sigma) (locked: unlock with TL Creds)
- phpAfterShell Related Community Infrastructure Contact — C2 / Ingress Transfer (Sigma) (locked: unlock with TL Creds)
- phpAfterShell PHP Worker Spawning Shell or Downloader — Post-Exploitation (SPL) (locked: unlock with TL Creds)
- phpAfterShell Related Community Infrastructure Contact — C2 / Ingress Transfer (SPL) (locked: unlock with TL Creds)

Sign up free to unlock the detection rules: https://threadlinqs.com/?modal=signup

## Sources

- [New phpAfterShell Attack Bypasses PHP2Shell Fix to Enable Remote Code Execution](https://cybersecuritynews.com/phpaftershell-rce/)
- [depthfirst: phpAfterShell: From Interrupted Session Writes to Remote Code Execution](https://depthfirst.com/research/phpaftershell)
- [NVD: CVE-2026-126714](https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2026-126714)
- [php-src GHSA-fm2m-fjf5-v3cp: Partially overwritten session files can lead to remote code execution](https://github.com/php/php-src/security/advisories/GHSA-fm2m-fjf5-v3cp)
- [php-src commit c2b02f24dff: ext/session: Truncate session file after successful write](https://github.com/php/php-src/commit/c2b02f24dffae346eef347db8a3323fbbe0f43fa)
- [Akamai: Understanding PHP2Shell - Everything You Need to Know](https://www.akamai.com/blog/security-research/2026/oct/understanding-php2shell-everything-you-need-to-know)
- [BleepingComputer: CISA confirms PHP2Shell vulnerabilities now exploited in attacks](https://bleepingcomputer.com/news/security/cisa-confirms-php2shell-vulnerabilities-now-exploited-in-attacks)
- [Astra: CVE-2026-115560 - Another PHP Session-Handler RCE](https://www.getastra.com/blog/?p=49824)
- [PHP.net: Security advisory - Critical remote code execution vulnerabilities, update now](https://www.php.net/archive/2026.php)
- [RFC 1867: Form-based File Upload in HTML](https://www.rfc-editor.org/rfc/rfc1867.html)

## Full data

The other 8 detection rules (Splunk SPL / Microsoft KQL / Sigma) unlock with TL Creds; a free account includes daily creds: https://threadlinqs.com/?modal=signup
Indicator values unlock with TL Creds, at a lower price on Red and Purple; AI agents can query rules and IOCs through the Threadlinqs MCP server (Purple and Gold in full, 2 calls a day on a free account): https://intel.threadlinqs.com/mcp

Canonical: https://intel.threadlinqs.com/threat/TL-2026-6478
