PHP Remote Code Execution Vulnerability (CVE-2026-126714)Security Advisory

Overview

Recently, NSFOCUS CERT monitored a security advisory released by PHP patching a remote code execution vulnerability (CVE-2026-126714), dubbed “phpAfterShell”. Because PHP’s default “files” session handler does not truncate existing content before updating a session file, an interrupted write operation can produce a malformed file containing a mix of old and new session data. If an unauthenticated attacker can influence session contents and interrupt a replacement write, PHP may deserialize attacker-controlled objects during subsequent session reads. This can result in session state corruption and, when a suitable deserialization gadget chain exists in the application, arbitrary code execution with the privileges of the PHP worker process. With a CVSS score of 9.2 and vulnerability details already publicly disclosed, affected users are urged to take protective measures as soon as possible.

Reference Link: https://github.com/php/php-src/security/advisories/GHSA-fm2m-fjf5-v3cp

Scope of Impact

Affected versions

  • PHP 8.5.x < 8.5.13
  • PHP 8.4.x < 8.4.28
  • PHP 8.3.x < 8.3.37
  • PHP 8.2.x < 8.2.36
  • 4.1.0 <= PHP < 8.2.0  (excluding official 7.4/8.0/8.1 EOL mitigation branches)

Note: This vulnerability affects deployments using the “files” session save handler. Officially End-of-Life (EOL) versions PHP 5, 7, 8.0, and 8.1 are also affected.

Unaffected versions

  • PHP 8.5.x >= 8.5.13
  • PHP 8.4.x >= 8.4.28
  • PHP 8.3.x >= 8.3.37
  • PHP 8.2.x >= 8.2.36
  • PHP = 7.4/8.0/8.1  EOL mitigation branches

Note: Deployments using other session save handlers such as Redis or databases are not affected by this vulnerability.

Detection

Manual Detection

Users can determine whether their current application falls within the affected scope by checking the PHP version and session save handler configuration:

1. Check the PHP version:

php -v

2. Check the session save handler to confirm whether session.save_handler is set to “files”:

php -r “echo ini_get(‘session.save_handler’) ?: ‘files(default)’, PHP_EOL;”

If the PHP version is within the affected range and the “files” session save handler is used, a security risk may exist.

Tool Detection

NSFOCUS’s automated penetration testing tool (EZ) now supports PHP fingerprint identification. Users can directly use the web module to scan and detect affected instances:

Tool Download Link: https://github.com/m-sec-org/EZ/releases

New users should register on the M-SEC Community (https://msec.nsfocus.com) to apply for a license certificate before use.

Mitigation

Official Upgrade

The vendor has released updated versions to fix this vulnerability. Affected users are advised to upgrade as soon as possible. Download link: https://www.php.net/downloads.php

Note: Users running PHP bundled in Linux distributions or third-party products should install the patched versions provided by the respective vendors, and restart PHP service processes such as PHP-FPM and Apache after upgrading.

Temporary Mitigations

Without impacting normal business operations, users can apply the following temporary mitigation measures:

1. Disable the session upload progress feature in php.ini and restart PHP worker processes:

session.upload_progress.enabled = 0

2. Restrict the amount of untrusted data stored in sessions to minimize attacker-controlled data entering session storage. Note that this measure only blocks certain input vectors and cannot remediate risks where the application independently stores attacker-controlled session data.

Statement

This advisory is only used to describe a potential risk. NSFOCUS does not provide any commitment or promise on this advisory. NSFOCUS and the author will not bear any liability for any direct and/or indirect consequences and losses caused by transmitting and/or using this advisory. NSFOCUS reserves all the rights to modify and interpret this advisory. Please include this statement paragraph when reproducing or transferring this advisory. Do not modify this advisory, add/delete any information to/from it, or use this advisory for commercial purposes without permission from NSFOCUS.

About NSFOCUS

NSFOCUS, a pioneering leader in cybersecurity, is dedicated to safeguarding telecommunications, Internet service providers, hosting providers, and enterprises from sophisticated cyberattacks.

Founded in 2000, NSFOCUS operates globally with over 3000 employees at two headquarters in Beijing, China, and Santa Clara, CA, USA, and over 50 offices worldwide. It has a proven track record of protecting over 25% of the Fortune Global 500 companies, including four of the five largest banks and six of the world’s top ten telecommunications companies.

Leveraging technical prowess and innovation, NSFOCUS delivers a comprehensive suite of security solutions, including the Intelligent Security Operations Platform (ISOP) for modern SOC, DDoS Protection, Continuous Threat Exposure Management (CTEM) Service and Web Application and API Protection (WAAP). All the solutions and services are augmented by the Security Large Language Model (SecLLM), ML, patented algorithms and other cutting-edge research achievements developed by NSFOCUS.

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *