❌

阅读视图

How Cloudflare WAF protects against ruby2shell (CVE-2026-132825)

On November 19, 2026, the Ruby team disclosed ruby2shell (CVE-2026-132825), a heap buffer overflow in the way Ruby changes the case of strings. Ruby rates the flaw Critical and says it is aware of proofs of concept that achieve remote code execution in some scenarios. Fixes shipped in Ruby 3.3.14, 3.4.13, and 4.0.10.

The reach is wide. Veria Labs reports that Ruby on Rails and classic-style Sinatra applications reach the bug in their default configuration, before any authentication. Self-hosted products that bundle Ruby, including GitLab, GitHub Enterprise Server, Mastodon, OpenProject, Discourse and Chatwoot, shipped an affected Ruby in their latest release at the time of disclosure.

Cloudflare WAF blocks ruby2shell for all customers, including those on the Free plan. We have added two rules to both the Cloudflare Free Managed Ruleset and the Cloudflare Managed Ruleset, with Block as the default action: one for ruby2shell and one for GHSA-87fm-7w84-j2px, a related integer overflow in Ruby string case conversion fixed in the same releases.

The WAF is a compensating control, not a replacement for patching. Exploits can reach the bug through paths a WAF does not see, and the only complete fix is to upgrade Ruby. Our team continues to monitor attack traffic and will update the rules as new techniques appear. You can track rule changes in the WAF changelog and get the latest on the vulnerability in the Cloudflare Zero Wire briefing.

Cloudflare has patched its own systems that use Ruby, and we have found no indication of compromise.

What we know about ruby2shell

Ruby strings carry an encoding, and Ruby still supports many legacy single-byte encodings, such as ISO-8859-1 (Latin-1) and Windows-1252, alongside UTF-8. In a single-byte encoding each character takes one byte, so changing the case of a string usually produces output of the same length.

The German sharp s (ß) breaks that assumption. Its uppercase form is two characters, SS. In 14 ISO-8859 and Windows-125x encodings, Ruby writes those two bytes but checks for room for only one. According to Veria Labs, a string with 21 sharp s characters overflows the output buffer by one byte. The methods that reach the bug are upcase, swapcase, downcase(:fold) and casecmp?. UTF-8 strings take a different code path and are not affected.

A one-byte overflow can look harmless. In a memory-corruption exploit, though, a single byte written past the end of a heap buffer can be enough to corrupt an adjacent object or allocator metadata. Ruby says it is aware of proofs of concept that turn this flaw into code execution, and Veria Labs says it will publish its own proof of concept about a week after disclosure. We expect scanning to start soon after.

Why default Rails and Sinatra apps are exposed

HTML forms can only send GET and POST requests. To simulate PUT, PATCH, or DELETE, many web frameworks accept a _method parameter in a POST request. Rack, the interface most Ruby web frameworks build on, implements this in its MethodOverride middleware, which converts the value of _method to uppercase. Rails includes this middleware by default, and classic-style Sinatra applications enable it. An attacker can send a multipart POST request whose _method part declares a legacy character set and contains a run of sharp s characters. The framework upcases the value while it is still routing the request, before any application code or authentication check runs.

Veria Labs reports that other frameworks and plain Rack applications are not exposed by default. Application code that changes the case of strings received in a legacy encoding may still be affected, wherever the string comes from.

Who is affected

Condition

Details

Ruby version

Ruby 3.3.13 and earlier, 3.4.0 through 3.4.12, and 4.0.0 through 4.0.9. Veria Labs reports the bug has been present since Ruby 2.4.0. Ruby 3.2 and earlier have reached end of life and will not receive the fix.

Framework

Rails and classic-style Sinatra in their default configuration. Any other code that changes the case of attacker-controlled strings in a legacy single-byte encoding.

Bundled software

As of November 19, 2026, Veria Labs lists GitLab 19.6.0, GitHub Enterprise Server 3.22.5, Mastodon 4.7.5, OpenProject 17.9.7, Discourse 2026.10.1 and Chatwoot 4.20.0 as bundling an affected Ruby in their latest release. Discourse moved its Docker base image to Ruby 4.0.10 on November 19, so rebuilding a Docker install picks up the fix.

Distribution packages can backport fixes without changing the Ruby version number, so check the full package version against your distribution's advisory.

Six more Ruby flaws in the same release

Ruby 3.3.14, 3.4.13, and 4.0.10 also fix six other memory safety flaws, and Ruby says several of them can lead to code execution. One, GHSA-87fm-7w84-j2px, is an integer overflow in the same string case conversion code, and our second WAF rule covers it. The other five are in Ruby's regular expression engine. Most of them require the application to compile or match a regular expression pattern supplied by the attacker. That is uncommon in web applications, but it does happen in search features, filtering rules and admin tools.

How Cloudflare WAF protects you

Upgrading every Ruby runtime takes time, especially when Ruby is bundled inside self-hosted products and container images. Cloudflare WAF reduces your exposure while you patch.

New managed rules, on for every customer

Both rules are part of the Cloudflare Free Managed Ruleset and the Cloudflare Managed Ruleset (Ruleset ID efb7b8c949ac4650a09736fc376e9aee), with Block as the default action.

Rule description

Rule ID

Ruleset

Default action

Ruby - Heap Overflow - CVE:CVE-2026-132825

7328f23691e44b07892ebd25b19210f1

Cloudflare Free Managed Ruleset (Free plan)

Block

Ruby - Heap Overflow - CVE:CVE-2026-132825

1afa543a1ed84893b01df04c34402c88

Cloudflare Managed Ruleset (Pro, Business and Enterprise plans)

Block

Ruby - Integer Overflow - GHSA-87fm-7w84-j2px

8660e37e86444f9f9267ba22e9855f05

Cloudflare Free Managed Ruleset (Free plan)

Block

Ruby - Integer Overflow - GHSA-87fm-7w84-j2px

6defac6a52334542adf4a162daf25922

Cloudflare Managed Ruleset (Pro, Business and Enterprise plans)

Block

On the Free plan, the Cloudflare Free Managed Ruleset runs automatically, so there is nothing to turn on. On paid plans, the rules are active wherever the Cloudflare Managed Ruleset is deployed. Because paid plans give you more control over how rulesets are deployed, the Cloudflare Managed Ruleset may not be active on every zone. We recommend checking its status to confirm that it is running. You can use the links in the Zero Wire briefing to go straight to the rules in your dashboard.

What the WAF cannot see

A WAF can block an exploit when the malicious input arrives in an HTTP request that passes through Cloudflare. It cannot block every path to the vulnerable code:

  • Traffic that bypasses Cloudflare. Requests sent directly to your origin IP address, and traffic between internal services, never reach the WAF. Configure your origin to accept traffic only from Cloudflare, for example with Cloudflare Tunnel or Authenticated Origin Pulls.
  • Other entry points into the same code. Ruby code that changes the case of strings from email, file imports, message queues or background jobs can reach ruby2shell without an HTTP request.

Adding defense in depth with WAF attack score

Memory corruption is usually only the first step. To run commands, an attacker still has to deliver a second-stage payload, such as shell commands or a reverse shell, and then interact with the compromised server. WAF attack score uses machine learning to score each request for remote code execution payloads, which helps catch exploit variations and post-exploitation traffic that signature-based rules can miss. Create a custom rule that blocks or challenges requests with cf.waf.score.rce le 20 on Enterprise plans, or cf.waf.score.class eq "attack" on Business plans.

Impact on Cloudflare infrastructure

Cloudflare has patched its systems that use Ruby against ruby2shell. We have found no indication of compromise and continue to monitor.

Patch now

ruby2shell turns a one-byte miscalculation in string case conversion into a pre-authentication path to code execution in default Rails and Sinatra apps. With a public proof of concept expected within days, the window to patch is short. Here is what to do:

  1. Check your WAF coverage. On the Free plan, the ruby2shell rules are already blocking. On paid plans, confirm the Cloudflare Managed Ruleset is deployed and the rules have not been overridden.
  2. Upgrade Ruby to 3.3.14, 3.4.13 or 4.0.10 and restart every Ruby process, including background workers. Rebuild container images. Move applications on Ruby 3.2 or earlier to a supported series.
  3. Update self-hosted products that bundle Ruby, such as GitLab, GitHub Enterprise Server, Mastodon, OpenProject and Chatwoot, as each vendor releases a fix. Rebuild Discourse Docker installs now.
  4. Inventory your runtimes. The Zero Wire briefing includes a prompt you can give an AI agent to find every affected Ruby runtime in your infrastructure.

Our WAF analysts will keep updating protections as new techniques appear. Follow the WAF changelog for rule updates.

  •  

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.

  •  
❌