12-04 更新 实时
首页/ 技术栈/ 正文

Cloudflare WAF 如何防护 phpAfterShell 等严重 PHP 漏洞

技术栈 来源:Cloudflare Blog 2026-11-21 04:00 0 阅读 机器翻译
Cloudflare WAF 如何防护 phpAfterShell 等严重 PHP 漏洞

2026 年 11 月 19 日,安全研究公司 depthfirst 披露了 phpAfterShell(CVE-2026-126714),这是 PHP 默认的基于文件的会话处理器中的一个漏洞,可导致远程代码执行。按照通用漏洞评分系统(CVSS)4.0,其评分为 9.2 分(满分 10 分,严重级别)。PHP 项目已于当天在 8.2.36、8.3.37、8.4.28、8.5.13 和 8.6.0 版本中修复该漏洞。这些版本还修复了另外 16 个安全漏洞,其中 6 个同样被评为严重级别。

Cloudflare 的 Web 应用防火墙(WAF)可拦截已知的 phpAfterShell 攻击模式,包括 Free 套餐的客户。该防护来自我们于 2026 年 10 月针对 php2shell 漏洞首次部署的 PHP 远程代码执行规则。在该漏洞披露之前,这条规则就已经能检测出 phpAfterShell 攻击模式的一部分,11 月 19 日我们更新了其检测逻辑,以覆盖 phpAfterShell。该规则同时属于 Cloudflare Free Managed Ruleset 和 Cloudflare Managed Ruleset,默认启用,默认动作为 Block(拦截)。

在同一次 WAF 发布中,我们为付费套餐的 Cloudflare Managed Ruleset 新增了三条规则:一条针对 PHP-FPM 中的请求走私漏洞(CVE-2026-129289),两条针对 PHP 的 SOAP 扩展中的漏洞(CVE-2026-15353 和 CVE-2026-129506),PHP 已在同一批版本中修复了这些漏洞。这些规则默认启用,动作为 Log(记录),因为它们所匹配的请求模式也可能出现在正常流量中,默认拦截可能会干扰正常流量。客户现在可以在 Security Events 中查看匹配的请求,并在确认规则不会影响正常流量后将动作改为 Block。

WAF 是一层额外的防御,并不能替代补丁。若干严重漏洞取决于服务器配置,或者可通过 WAF 看不到的路径触达,唯一完整的修复方法是升级 PHP 并重启每个 worker。我们的分析师持续监控攻击活动,并将在出现新技术和变种时更新规则。你可以在 WAF 变更日志中跟踪规则变更,并在专门的 Cloudflare Zero Wire 简报中跟进这些漏洞的发展。

到目前为止,似乎没有迹象表明这些漏洞已被利用。截至 2026 年 11 月 19 日,这 17 个漏洞均未被列入 CISA 的已知被利用漏洞目录,我们审阅过的来源也没有报告在野利用。

默认情况下,PHP 将会话数据存储在文件中。当应用程序调用 session_start() 时,PHP 会读取会话文件,并将其内容反序列化到 $_SESSION 数组中。当请求结束时,PHP 会将更新后的会话写回同一文件。

当该写入被中断时,就会触发 phpAfterShell。此时会话文件可能保存着新会话数据的开头,后面接着旧会话数据的结尾。在下一次请求时,session_start() 会反序列化这段混合内容。如果攻击者控制了旧数据,PHP 最终可能会反序列化攻击者选定的对象。

试图利用该漏洞的攻击者,很可能会首先寻找一种将受控数据放入会话的方法。PHP 的安全公告列出了两种:

根据 PHP 的说法,代码执行还需要在写入过程中的某个有用位置发生中断,以及应用中存在合适的反序列化 gadget 链。depthfirst 报告称,它通过串联一个 PHP 原生类中第二个未公开的内存破坏漏洞,在没有应用 gadget 的情况下实现了代码执行。我们查阅的来源并未确认第二个漏洞是否已在 11 月 19 日的版本中修复。

depthfirst 表示,它发现并报告了 phpAfterShell。CVE 记录将 Leo Lin 和 Asahi 列为报告者。

同一批版本还修复了另外六个严重漏洞。每个漏洞都需要特定配置才能被利用:

CVE-2026-129289

未经身份验证的攻击者可以向 PHP-FPM 中夹带第二个 FastCGI 请求,并以 worker 身份运行 PHP 代码。

复用后端 FastCGI 连接的前端(开启 fastcgi_keep_conn 的 nginx、启用 enablereuse=on 的 Apache mod_proxy_fcgi,或 HAProxy)、打开 php://input 但未读取到末尾的应用路径,以及现有 PHP 脚本的路径。

CVE-2026-115560

会话序列化器

通过会话序列化器之间的不匹配实现对象注入。该问题首次在我们的 php2shell 简报中披露,现已修复。

在启用会话上传进度的情况下触发。PHP 扩大了影响范围:使用不同序列化器并共享同一会话存储的应用程序、进程池或命令行任务都会受到影响。

CVE-2026-129496

时区缓存

释放后使用(use-after-free)漏洞,可导致新启动的 worker 崩溃,并可能执行代码。PHP 在本地利用已知内存地址演示了代码执行。

非线程安全构建,且启动诊断信息已被写入 PHP 错误日志文件的情况。

CVE-2026-129481

会话关闭

释放后使用(use-after-free),PHP 将其描述为 CVE-2026-109619 的不完整修复。未演示代码执行。

PHP 8.3 及更高版本。

CVE-2026-129474

致命错误回溯

魔术方法回溯中的释放后使用(use-after-free)。

PHP 8.5 及更高版本,其中致命错误回溯默认启用。设置 zend.exception_ignore_args=1(php.ini-production 的默认值)可阻止已演示的攻击。

CVE-2026-129182

致命错误回溯

释放后使用。未演示代码执行。

PHP 8.5、特定的路径级设置,以及会产生早期诊断的 Apache 按目录配置或前端。

受影响版本为 PHP 8.2(低于 8.2.36)、8.3(低于 8.3.37)、8.4(低于 8.4.28)、8.5(低于 8.5.13),以及 8.6.0 候选发布版本。某个部署是否暴露,取决于每个漏洞的具体条件。

PHP 8.1 及更早版本已停止支持(end-of-life)。depthfirst 表示,官方的 7.4、8.0 和 8.1 停止支持缓解分支不受 phpAfterShell 影响,但 PHP 表示 CVE-2026-129289 是在 PHP 5.6.0 中引入的,且早于 8.2 的版本也可能受到 CVE-2026-115560 影响。

Linux 发行版通常会在不更改 PHP 版本号的情况下向后移植修复。请对照你的发行版安全公告检查完整软件包版本。

PHP 运行在网络的很大一部分中,常常位于团队不会直接更新的内容管理系统、插件和容器镜像内。修补每一个 PHP 运行时需要时间。Cloudflare WAF 可在你修补期间降低你的暴露风险。

我们在 2026 年 10 月 21 日的一次紧急发布中发布了最初的 PHP 远程代码执行规则,此前 php2shell 漏洞(CVE-2026-109618 和 CVE-2026-109619)已被披露。我们在 10 月 23 日将这些规则扩展到 CVE-2026-115560,并在随后几周内多次优化,部分依据来自参加 PHP Capture the Flag (CTF) 挑战赛的安全研究人员的报告。

phpAfterShell 与 php2shell 共享一种攻击技术:攻击者将序列化的 PHP 数据植入会话存储,然后等待 PHP 对其进行反序列化。由于这种重叠,现有规则在披露之前就已经匹配到了 phpAfterShell 攻击模式的一部分。11 月 19 日,我们更新了该规则的检测逻辑以覆盖 phpAfterShell,并在其描述中添加了 CVE-2026-126714。

规则描述

默认操作

PHP 远程代码执行攻击(CVE-2026-109618、CVE-2026-109619、CVE-2026-115560、CVE-2026-126714)#6

19373a83abb840e18ab3ce5a7975ce1b

Cloudflare Free Managed Ruleset(免费套餐)

PHP 远程代码执行攻击(CVE-2026-109618、CVE-2026-109619、CVE-2026-115560、CVE-2026-126714)#6

4148ae686fdb4d01be673fab9d9c073d

Cloudflare Managed Ruleset(Pro、Business 和 Enterprise 计划)

Free 计划客户无需采取任何操作。在付费计划中,只要部署了 Cloudflare Managed Ruleset,该规则就会生效。你可以使用 Zero Wire 简报中的链接,直接跳转到仪表盘中的规则。

这三条新规则属于 Cloudflare Managed Ruleset(Ruleset ID efb7b8c949ac4650a09736fc376e9aee),适用于 Pro、Business 和 Enterprise 计划。

规则描述

默认操作

PHP-FPM - CVE:CVE-2026-129289

8ef1c34a424b4ccfa6f6fe186c6f42b2

PHP SOAP - CVE:CVE-2026-15353

5c5a9d6397e44837a3214b5ba54028d4

PHP SOAP - CVE:CVE-2026-129506

00a23de67a684876ba67c5d44521b819

要查看它们的匹配项,请转到 Security > Analytics > Events,并按规则 ID 进行筛选。如果匹配到的并非合法流量,请将规则操作改为 Block:转到 Security > Settings,编辑 Cloudflare Managed Ruleset,搜索该 CVE 标识符并将规则操作设为 Block,或者您也可以参考 Zero Wire 简报中的链接,直接前往规则配置。

当恶意数据通过经过 Cloudflare 的 HTTP 请求到达时,WAF 可以阻止漏洞利用。但它无法阻止通往这些漏洞的所有路径,包括:

WAF 攻击评分增加了一个机器学习层,会对每个请求的攻击载荷进行评分。它适用于 Business 套餐(cf.waf.score.class),而在 Enterprise 套餐中,还提供专用的远程代码执行子评分(cf.waf.score.rce)以及总体评分(cf.waf.score)。

原文较长,译文为节选;译文由英文原文机器翻译,术语按行业惯例统一,可在文末展开原文核对。

查看英文原文(How Cloudflare WAF helps protect against phpAfterShell and other critical PHP flaws)

On November 19, 2026, the security research company depthfirst disclosed phpAfterShell (CVE-2026-126714), a vulnerability in PHP's default file-based session handler that can lead to remote code execution. Under the Common Vulnerability Scoring System (CVSS) 4.0, it scores 9.2 out of 10 (Critical). The PHP project fixed it the same day in versions 8.2.36, 8.3.37, 8.4.28, 8.5.13, and 8.6.0. These releases fix 16 other security vulnerabilities, six of them also rated critical.

Cloudflare’s web application firewall (WAF) blocks known phpAfterShell attack patterns, including for customers on the Free plan. The protection comes from a PHP remote code execution rule we first deployed in October 2026 for the php2shell vulnerabilities. That rule already detected part of the phpAfterShell attack pattern before the vulnerability was disclosed, and on November 19 we updated its detection logic to cover phpAfterShell. The rule is part of both the Cloudflare Free Managed Ruleset and the Cloudflare Managed Ruleset, is enabled by default, and its default action is Block.

In the same WAF release, we added three new rules to the Cloudflare Managed Ruleset for paid plans: one for a request smuggling flaw in PHP-FPM (CVE-2026-129289), and two for flaws in PHP's SOAP extension (CVE-2026-15353 and CVE-2026-129506) that PHP fixed in the same releases. These rules are enabled by default with the Log action, because the request patterns they look for can also appear in legitimate traffic, and blocking by default could disrupt it. Customers can review matching requests in Security Events now and change the action to Block once they confirm the rules do not affect legitimate traffic.

The WAF is an additional layer of defense, not a replacement for the patch. Several of the critical flaws depend on server configuration or can be reached through paths a WAF does not see, and the only complete fix is to upgrade PHP and restart every worker. Our analysts continue to monitor attack activity and will update the rules as new techniques and variations appear. You can track rule changes in the WAF changelog and follow how the vulnerabilities develop in the dedicated Cloudflare Zero Wire briefing.

There appears to be no indication so far that these vulnerabilities have been exploited. As of November 19, 2026, none of the 17 vulnerabilities was listed in CISA's Known Exploited Vulnerabilities catalog, and no source we reviewed reports exploitation in the wild.

What we know about phpAfterShell

PHP stores session data in files by default. When an application calls session_start(), PHP reads the session file and deserializes its content into the $_SESSION array. When the request ends, PHP writes the updated session back to the same file.

phpAfterShell is triggered when that write is interrupted. The session file can then hold the beginning of the new session data followed by the end of the old one. On the next request, session_start() deserializes this mixed content. If an attacker controlled the old data, PHP can end up deserializing objects of the attacker's choice.

An attacker trying to exploit the flaw is likely to first search for a way to place controlled data in the session. PHP's advisory names two:

  • Session upload progress, a PHP feature that writes information about a running file upload into the session. A remote client can use it to shape the stored data.
  • Applications that store large user-controlled strings in the session.

According to PHP, code execution also requires an interruption at a useful point in the write and a suitable deserialization gadget chain in the application. depthfirst reports that it reached code execution without an application gadget by chaining a second, undisclosed memory-corruption bug in a PHP-native class. The sources we reviewed do not establish whether that second bug is fixed in the November 19 releases.

depthfirst says it discovered and reported phpAfterShell. The CVE record credits Leo Lin and Asahi as reporters.

The other critical flaws

The same releases fix six more critical vulnerabilities. Each one needs a specific configuration to be exploitable:

CVE

Component

Impact

Conditions

CVE-2026-129289

PHP-FPM

An unauthenticated attacker can smuggle a second FastCGI request into PHP-FPM and run PHP code as the worker.

A front end that reuses backend FastCGI connections (nginx with fastcgi_keep_conn on, Apache mod_proxy_fcgi with enablereuse=on, or HAProxy), an application path that opens php://input without reading it to the end, and the path of an existing PHP script.

CVE-2026-115560

Session serializer

Object injection through a mismatch between session serializers. First covered in our php2shell briefing, now fixed.

Session upload progress enabled. PHP widened the scope: applications, pools or command-line jobs that use different serializers and share a session store are affected.

CVE-2026-129496

Timezone cache

Use-after-free that can crash a fresh worker and possibly run code. PHP demonstrated code execution locally with known memory addresses.

Non-thread-safe builds where a startup diagnostic has been written to a PHP error log file.

CVE-2026-129481

Session shutdown

Use-after-free, described by PHP as an incomplete fix for CVE-2026-109619. No code execution demonstrated.

PHP 8.3 and later.

CVE-2026-129474

Fatal error backtraces

Use-after-free in magic method backtraces.

PHP 8.5 and later, where fatal error backtraces are enabled by default. Setting zend.exception_ignore_args=1, the php.ini-production default, blocks the demonstrated attack.

CVE-2026-129182

Fatal error backtraces

Use-after-free. No code execution demonstrated.

PHP 8.5, specific path-level settings, and an Apache per-directory configuration or front end that produces an early diagnostic.

Who is affected

The vulnerable versions are PHP 8.2 before 8.2.36, 8.3 before 8.3.37, 8.4 before 8.4.28, 8.5 before 8.5.13, and the 8.6.0 release candidates. Whether a deployment is exposed depends on the conditions of each flaw.

PHP 8.1 and earlier are end-of-life. depthfirst says the official 7.4, 8.0 and 8.1 end-of-life mitigation branches are not affected by phpAfterShell, but PHP says CVE-2026-129289 was introduced in PHP 5.6.0 and that releases older than 8.2 may also be affected by CVE-2026-115560.

Linux distributions often backport fixes without changing the PHP version number. Check the full package version against your distribution's advisory.

How Cloudflare WAF protects you

PHP runs a large share of the web, often inside content management systems, plugins, and container images that teams do not update directly. Patching every PHP runtime takes time. Cloudflare WAF reduces your exposure while you patch.

phpAfterShell: protection on every plan

We released the original PHP remote code execution rules in an emergency release on October 21, 2026, after the php2shell vulnerabilities (CVE-2026-109618 and CVE-2026-109619) were disclosed. We extended them to CVE-2026-115560 on October 23 and refined them several times in the following weeks, based in part on reports from security researchers who took part in a PHP Capture the Flag (CTF) challenge.

phpAfterShell shares an attack technique with php2shell: an attacker plants serialized PHP data in session storage and waits for PHP to deserialize it. Because of that overlap, the existing rule already matched part of the phpAfterShell attack pattern before disclosure. On November 19, we updated the rule's detection logic to cover phpAfterShell and added CVE-2026-126714 to its description.

Rule description

Rule ID

Ruleset

Default action

PHP Remote Code Execution Attack (CVE-2026-109618, CVE-2026-109619, CVE-2026-115560, CVE-2026-126714) #6

19373a83abb840e18ab3ce5a7975ce1b

Cloudflare Free Managed Ruleset (Free plan)

Block

PHP Remote Code Execution Attack (CVE-2026-109618, CVE-2026-109619, CVE-2026-115560, CVE-2026-126714) #6

4148ae686fdb4d01be673fab9d9c073d

Cloudflare Managed Ruleset (Pro, Business and Enterprise plans)

Block

Free plan customers do not need to take any action. On paid plans, the rule is active wherever the Cloudflare Managed Ruleset is deployed. You can use the links in the Zero Wire briefing to go straight to the rules in your dashboard.

New rules for PHP-FPM and SOAP flaws

The three new rules are part of the Cloudflare Managed Ruleset (Ruleset ID efb7b8c949ac4650a09736fc376e9aee) and are available on Pro, Business and Enterprise plans.

Rule description

Rule ID

Default action

PHP-FPM - CVE:CVE-2026-129289

8ef1c34a424b4ccfa6f6fe186c6f42b2

Log

PHP SOAP - CVE:CVE-2026-15353

5c5a9d6397e44837a3214b5ba54028d4

Log

PHP SOAP - CVE:CVE-2026-129506

00a23de67a684876ba67c5d44521b819

Log

To review their matches, go to Security > Analytics > Events and filter by rule ID. If the matches are not legitimate traffic, change the rule action to Block: go to Security > Settings, edit the Cloudflare Managed Ruleset, search for the CVE identifier and set the rule action to Block, or you can refer to the links in the Zero Wire briefing to go straight to the rules configuration.

What the WAF cannot see

A WAF can block an exploit when the malicious data arrives in an HTTP request that passes through Cloudflare. It cannot block every path to these vulnerabilities, including:

  • The deserialization step. phpAfterShell's final step happens inside PHP, when it reads a corrupted session file. The WAF can block the requests that plant the payload, not the read itself.
  • Session data from other sources. If an application copies user-controlled data into the session from a database, a queue or an upstream API, that data may never cross the WAF in a recognizable form.
  • Flaws triggered by server state. CVE-2026-129496, CVE-2026-129481, CVE-2026-129474 and CVE-2026-129182 depend on error logs, diagnostics and worker lifecycle. They do not have dedicated WAF rules, and the patch and the configuration changes below are the way to address them.
  • Traffic that bypasses Cloudflare. This includes internal traffic between services and PHP-FPM listeners exposed directly to a network.

Adding defense in depth with WAF attack score

WAF attack score adds a machine learning layer that scores each request for attack payloads. It is available on Business plans (cf.waf.score.class) and, with a dedicated remote code execution sub-score (cf.waf.score.rce) along with an overall score (cf.waf.score), on Enterprise plans.

Attack score complements the managed rules. It will not recognize every serialized object or smuggled FastCGI record on its own, but a working exploit chain usually needs more than one request, and the later stages carry payloads the model is trained to score:

  • Second-stage payloads. Once an attacker can run code, they still need to send commands: shell execution primitives (/bin/sh -c, system(), passthru()), PHP code evaluation (eval(), assert()) or reverse-shell strings in headers, query parameters or request bodies.
  • Webshell traffic. Attackers often drop a small PHP webshell after the initial compromise. Requests that pass operating system commands to that webshell remain visible to attack score.

Deploy protections and patch

You can find more information on how to deploy managed rules and attack score in our WAF guide. In short:

  1. Check that phpAfterShell protection is active. On the Free plan, no action is needed. On paid plans, make sure the Cloudflare Managed Ruleset is deployed and that the PHP Remote Code Execution Attack #6 rule is set to Block.
  2. Review the new rules and switch them to Block. The CVE-2026-129289, CVE-2026-15353 and CVE-2026-129506 rules are in Log mode by default. Review their matches in Security Events, then change their action to Block.
  3. Layer attack score. Create a custom rule that blocks or challenges requests with a low remote code execution score, for example cf.waf.score.rce le 20 on Enterprise plans, or cf.waf.score.class eq "attack" on Business plans.
  4. Upgrade PHP. Move to 8.2.36, 8.3.37, 8.4.28, 8.5.13 or 8.6.0. Rebuild container images and restart the PHP-FPM master or Apache so every worker loads the new binary, then verify the version that serves web requests. After upgrading, check that no php.ini, FPM pool or virtual host still sets session.upload_progress.enabled=1, because an explicit setting overrides the new default.
  5. Apply interim mitigations if you cannot upgrade right away. Set session.upload_progress.enabled=0 and limit the untrusted data you store in sessions. Turn off FastCGI connection reuse. On PHP 8.5, set fatal_error_backtraces=0. Fix configuration errors that produce PHP startup warnings, or send PHP errors to syslog instead of a file. Keep PHP-FPM listeners off untrusted networks. These steps reduce exposure; they do not fix the flaws.

For a prompt you can give an AI agent to inventory your PHP deployments and check each one against all seven critical CVEs, see the phpAfterShell page on Cloudflare Zero Wire.

Update every PHP runtime now

phpAfterShell turns an interrupted file write in PHP's default session handler into a path to code execution, and it arrived in the same release as six other critical flaws. With technical details now public, we expect exploit attempts to follow. Cloudflare WAF blocks known phpAfterShell attack patterns for every customer, including the Free plan, and paid plans have new rules for the PHP-FPM and SOAP flaws. The fix is still to upgrade PHP and restart the services that use it.

正文保留英文原文,标题与摘要由机器翻译。

本文由采集器自动同步

原文发布于 Cloudflare Blog(How Cloudflare WAF helps protect against phpAfterShell and other critical PHP flaws),标题、摘要与正文由机器翻译,术语按行业惯例统一,未经人工逐句校订。

阅读原文 ↗