phpAfterShell (CVE-2026-126714): Torn Session Files in PHP's Default Handler Lead to Remote Code Execution and Bypass the PHP2Shell Fix

Critical · 2026-11-21 · By H.A

phpAfterShell (CVE-2026-126714): Torn Session Files in PHP's Default Handler Lead to Remote Code Execution and Bypass the PHP2Shell Fix

A critical race in PHP's default files session handler (CVSS 9.2) lets an interrupted write mix old and new session data into injected objects and code execution; fixed in PHP 8.2.36, 8.3.37, 8.4.28, 8.5.13 and 8.6.0.

Overview

PHP has patched CVE-2026-126714, nicknamed phpAfterShell: a critical flaw in the default "files" session handler (ext/session). It is rated CVSS v4.0 9.2 (Critical). When PHP rewrites a session file and the write is interrupted, the file can end up holding the start of the new session followed by the tail of the old one. On the next request, PHP reads this mixed file back, and bytes that were only harmless text inside a string can come back as live PHP objects. With a usable deserialization chain, that becomes remote code execution in the PHP worker. Without one, an attacker can still tamper with session values such as identity, roles or CSRF tokens.

The bug went out in the same PHP security release as 16 other CVEs, published on 19 November 2026 at 18:00 Mauritius time (14:00 UTC). Seven of them are rated 9.2. phpAfterShell is a separate flaw from PHP2Shell (CVE-2026-109619) from October: the October patch does not protect against it. Servers patched last month are still exposed until they move to the November builds.

The Vulnerability

How PHP saves a session

With the default session.save_handler = files, each session lives in a file such as /var/lib/php/sessions/sess_<id>. The file is a plain run of key|serialized_value records. There is no overall length field, checksum or "write finished" marker. On load, the decoder reads up to a |, unserializes the value after it, and treats the next byte as the start of the next key.

On save, ps_files_write() writes the new data into the existing file from offset 0 using pwrite(). In the vulnerable code, PHP only trims the file when the new data is shorter than the old file. If the new data is the same size or longer, the old bytes stay in place until the new bytes cover them.

Why an interrupted write is dangerous

PHP holds an exclusive flock() on the session file. That stops two requests writing at once, but it does not make the write atomic. If the worker dies part-way through, nothing rolls the file back. If only the first k bytes of the new session were written, the file now holds:

new_session[0:k] + old_session[k:]

PHP's own short-write check never runs, because the process is already dead. According to the advisory, in threaded PHP builds a hard memory-limit failure in another thread can kill the whole process mid-write. This gives an attacker some control over where the write stops.

Getting attacker bytes into the session

The easiest way to put attacker data into a session file is session upload progress (session.upload_progress.enabled, which is on by default). When a multipart upload includes a PHP_SESSION_UPLOAD_PROGRESS field, PHP writes an upload_progress_<name> entry into the session before any application code runs. That entry contains the form field name and the uploaded file's name, both chosen by the attacker. Any application that stores long user-supplied strings in $_SESSION gives the same opening.

Timeline

Tradecraft

This is how the attack works according to the published research. We describe it for defenders and leave out working exploit details.

Why the PHP2Shell patch does not help: the October fix made objects seen during the upload-progress callback load as __PHP_Incomplete_Class. Here, the object only appears on a later session_start(), after that restriction has been lifted, so it loads normally.

The attack is noisy and probabilistic. It needs many requests to control memory pressure and timing, and works best against PHP running in memory-limited containers (Apache mod_php or PHP-FPM) with file sessions.

IOCs

No file hashes, domains or IP addresses have been published for CVE-2026-126714. With no confirmed exploitation, there is no attacker infrastructure to list. Hunt for behaviour instead:

Detection

Recommended Actions

Analyst Assessment

Severity: Critical, and patch priority is high even though exploitation is complex. phpAfterShell is a design weakness that has existed for a very long time: PHP's advisory traces the code path back to PHP 4.1.0. It sits in the default configuration of the world's most widely deployed server-side language. Reliable exploitation is hard: it needs precise memory and timing control and works best on containerised PHP with tight memory limits. That probably explains the "attack requirements present" rating in the CVSS score.

Three things push us to treat it as urgent anyway. First, the researchers have shown a full end-to-end chain and say it needs no application gadget. Once that native chain becomes public or is reproduced, the "you need a gadget" safety margin disappears. Second, PHP2Shell was weaponised within days last month and ended up in CISA KEV, which shows how quickly attackers move on PHP core bugs. Third, organisations that rushed out the October patch may believe they are covered. They are not.

We expect a public proof-of-concept within weeks and opportunistic scanning against PHP hosts that remain unpatched. Patch, restart, disable upload progress where it isn't needed, and move high-value applications to non-file session storage.

Sources

COMPUTE NODE · · --:--:--

Fresh cybersecurity news,
daily threat intelligence.

Daily cyber news, live threat intel and exploited CVEs.

Everything in one place

Self-hosted, hardened, and yours.

RUN IT

Local AI console

Chat with a model on your own hardware via Ollama or any OpenAI-compatible server. No cloud, no key.

DEFEND

Cyber threat feed

Automatic daily intel from CISA KEV, NVD & GitHub advisories, a live cyber threat map, and your own notes.

NEWS

News & videos

Articles and updates on pentesting, AI, and cyber — with embedded video, including YouTube. Post your own.

DIRECTORY

Registry

Runtimes, models, MCP servers, agents, and a full security & pentest tooling section.

PUBLISH

Posts

Write, edit, publish, and share articles backed by a real database and your account.

COMMUNITY

Forum

Threads and replies across categories from Models to Hardware to Security.

CODE

Repos

Curated AI and security GitHub repos, plus a shelf for pinning your own.

DOWNLOAD

Skill packs

Agent starters, RAG scaffolds, and defensive security & VAPT report templates.

Registry

Runtimes, models, MCP servers, agent frameworks, and a security & pentest tooling section — all links out to the real projects.

Local AI console

Talk to a model running on your own machine through Ollama or an OpenAI-compatible server — your prompts and the model's replies always go straight from your browser to your local model, never through a Reef server. Attach files for context, and pick up saved chats where you left off.

Type /image a prompt in the box below to generate
Not connected

Local AI hardware benchmark

A spec-based compatibility advisor — tells you which local models your hardware can run well, which will be slow, and which to skip. Connect to Ollama below for a real, measured speed test instead of an estimate.

1. Your hardware

2. Live check against your local model server (optional)

If a local model server is running, this cross-references the table above with what you've actually got loaded — and runs a real, measured speed test instead of an estimate.

AI Database

A browsable catalog of AI models across providers — context windows, pricing, and capabilities.

Loading…

Cyber threat feed

Latest threats pulled automatically every day from CISA's Known-Exploited-Vulnerabilities catalog and NVD — plus threat intel you post yourself.

⇩ Export STIX
Loading threat feed…

Cyber threat map

Attacks happening right now, all over the world.

Connecting…
LIVE · MAURITIUS TIME--:--:--
attack route, country to country attack route into Mauritius attacker reported worldwide
Loading live data…
attackers reported per minute · click to rewindnow

Top attack routesweb

Attackers based inlast hour

Networkslast hour

Click any dot, feed row or table row to see that IP's profile.

Mauritius

Who attacks Mauritius

Loading…

Web attacks malicious requests to Mauritian websites that were blocked
Network DDoS floods meant to knock Mauritian servers offline

    Mauritius · last 24 h

    How Mauritius is attacked

    Network-level attacks (DDoS) aimed at Mauritius, by method. They try to knock servers and networks offline by sheer volume.

    • Loading…

    The ports or services these floods aimed at aren't published.

    Mauritius · last hour

    Attackers located in Mauritius

    0attackers located in Mauritius were reported in the last hour

    This counts attacks coming from Mauritius, not attacks on it: IPs in Mauritius that servers elsewhere reported for attacking them. Usually zero or one; when it rises, it's often a hacked local server or router.

    Worldwide today

    What attackers are knocking on

    Ports most targeted across a worldwide network of sensors .

    Worldwide today

    Most active attackers

    Ranked by how many separate sensors they hit. Click a row for its profile.

    IPCountryNetworkSensors hitReports
    What you're looking at
    Blue routes

    Share of attack traffic from one country to another. Thicker, faster streams carry more. Particles show volume, not one per attack.

    Every 15 min · published 1–2 h behind
    Amber flashes

    An attacking IP that servers around the world reported in the last minute, placed where the IP is. Its targets aren't published, so there's no line.

    Every minute · shown about 1 min behind
    Locations

    IP locations are approximate (city level at best) and show where the machine is hosted, not who controls it.

    Approximate · city level at best

    News

    Articles, guides and updates on pentesting, AI, and cybersecurity — with embedded video. Add your own, including YouTube.

    Loading…

    Posts

    Loading…

    Loading posts…

    Forum

    Questions, answers, and talk about running AI locally.

    Loading forum…

    GitHub repositories

    Curated AI and security repos, plus your own pinned shelf.

    Command board

    One-liners, configs, and advice worth keeping — shared by everyone here.

    ⚠ Commands are shared with all users. Never include credentials, tokens, or internal hostnames. Review anything before you run it.
    Loading commands…

    Skill packs

    Starter files served from the API — AI agent scaffolds plus defensive security & VAPT reporting templates. Click to download.

    Loading skills…

    Your watchlist

    Follow threat actors, malware, CVEs and vendors — we tell you when a new report, CVE record or exploitation alert mentions them.

    Threat Library

    Threat actors, malware and tools — their attack techniques, Reef Sentinel coverage and indicators of compromise.

    Loading…

    Threat Intelligence

    Curated threat write-ups, advisories and analysis — with cover media.

    Loading…

    Tutorials

    Step-by-step guides for running local AI, using the console, and tracking threats. Admins can add their own.

    Loading…

    Downloads

    Direct links to the official homepage/download page for well-known cybersecurity, penetration-testing, and local-AI software. Always verify checksums/signatures from the vendor before running anything.

    Loading…

    Privacy Policy

    Loading…

    Terms & Conditions

    Loading…

    Help & FAQ

    Answers to common questions about Reef Sentinel, plus a formatting guide for posts, articles, and comments.


    Formatting guide

    Commands you can type into the body of a post, comment, or reply — no HTML needed. Comments and short replies only support bold, italic, and inline code.

    Contact us

    Questions, feedback, or a security disclosure? Reach us directly, or send a message and we'll get back to you by email.

    Loading…

    Send a message

    VAPT Report Generator

    Build an engagement, add findings with a live CVSS calculator, and generate a branded, print-ready report.

    Recon Toolkit

    Investigate any domain, IP, URL, file hash, email or CVE in one search, plus breach and password checks, hash identification and a payload cheatsheet.

    Outage Monitor

    Is Microsoft 365, Facebook, Google, AWS or ChatGPT down? Live status of the big tech services from their official status pages, every incident with its full timeline, and how long each one took to fix.

    Website Checker

    Reads a website's HTTP response headers to identify its framework and server, shows any known CVEs for the exposed versions with details, and recommends what to do.

    Control panel

    Manage everything shown on the site — news & videos, posts, homepage headlines, and subscribers. Admin only.

    Overview
    Content
    Site
    Account & Security

    Email settings

    SMTP on ports 25/465/587 is blocked outbound by some hosts (e.g. DigitalOcean droplets by default) — Resend and Brevo send over their HTTPS API instead, so they work even then. Only the selected provider is used to send; the others stay saved but idle, so you can switch back any time without losing settings.

    Get a key from resend.com/api-keys. Uses the "From address" below as the sender — it must be on a domain you've verified with Resend.

    Get an API key (not an SMTP key) from app.brevo.com/settings/keys/api. Uses the "From address" below as the sender — it must be a verified sender in your Brevo account.

    "From address" and "Site name/URL" are shared by SMTP, Resend, and Brevo — they control what recipients see, regardless of which provider is active.

    Send a test email

    Sends through whichever provider is currently active above. Save your settings first if you just changed them.

    SIGNAL LOST

    We couldn't find this page

    The page may have been moved or deleted, or the address was mistyped.