When a critical vulnerability hits a core language like PHP or Ruby, the window between disclosure and exploitation is narrow. If you use Cloudflare WAF, you already have a layer of protection active against two major flaws disclosed on November 19, 2026: phpAfterShell (CVE-2026-126714) and ruby2shell (CVE-2026-132825). This article explains how these vulnerabilities work, how Cloudflare’s managed rulesets block them, and what you must do in your own environment to secure your backend applications.
Understanding the Threat: phpAfterShell and ruby2shell
Both vulnerabilities allow remote code execution (RCE), but they exploit different parts of the stack. It's important to understand their mechanics to appreciate why a Web Application Firewall (WAF) is a necessary, though not sufficient, defense.
phpAfterShell: A Critical PHP Vulnerability
Disclosed by security research firm depthfirst, phpAfterShell (CVE-2026-126714) is 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, placing it in the Critical category.
The PHP project fixed this vulnerability on the same day it was disclosed, in versions 8.2.36, 8.3.37, 8.4.28, 8.5.13, and 8.6.0. These releases also address 16 other security vulnerabilities, six of which are also rated critical.
ruby2shell: Heap Buffer Overflow in String Case Conversion
Disclosed by the Ruby team, ruby2shell (CVE-2026-132825) is a heap buffer overflow in how Ruby changes the case of strings. Ruby rates this flaw Critical, noting awareness of proofs of concept that achieve remote code execution in some scenarios.
The bug stems from a mismatch between expected and actual output lengths in legacy single-byte encodings like ISO-8859-1 (Latin-1) and Windows-1252. Ruby strings carry an encoding, and many legacy single-byte encodings are still supported alongside UTF-8. In these single-byte encodings, each character typically takes one byte, so changing the case of a string usually produces output of the same length.
However, 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.
While a one-byte overflow might seem minor, in memory-corruption exploits, it can be enough to corrupt an adjacent object or allocator metadata. The methods that reach the bug are upcase, swapcase, downcase(:fold), and casecmp?. UTF-8 strings are not affected because they take a different code path.
The reach of this flaw is wide. Veria Labs reports that Ruby on Rails and classic-style Sinatra applications are vulnerable in their default configuration, even before authentication. This is because Rack’s MethodOverride middleware, which converts the _method parameter to uppercase for simulated PUT/PATCH/DELETE requests, triggers the bug during request routing. 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.
Fixes are available in Ruby 3.3.14, 3.4.13, and 4.0.10.
How Cloudflare WAF Blocks These Attacks
Cloudflare’s WAF provides immediate, out-of-the-box protection for both vulnerabilities. This protection is available to all customers, including those on the Free plan.
Managed Ruleset Configuration
Cloudflare has updated both the Cloudflare Free Managed Ruleset and the Cloudflare Managed Ruleset. The rules are enabled by default with a Block action.
- ruby2shell Rule: Blocks known attack patterns for CVE-2026-132825.
- GHSA-87fm-7w84-j2px Rule: Blocks a related integer overflow in Ruby string case conversion, fixed in the same Ruby releases.
- PHP RCE Rule: For phpAfterShell, Cloudflare updated an existing PHP remote code execution rule originally deployed in October 2026 for php2shell vulnerabilities. This rule already detected part of the phpAfterShell attack pattern before disclosure. On November 19, 2026, the detection logic was updated to fully cover phpAfterShell.
Additional Rules for Paid Plans
In the same WAF release, Cloudflare added three new rules to the Cloudflare Managed Ruleset for paid plans. These target other critical flaws fixed in the same PHP releases:
- CVE-2026-129289: A request smuggling flaw in PHP-FPM.
- CVE-2026-15353 & CVE-2026-129506: Flaws in PHP’s SOAP extension.
Unlike the PHP and Ruby RCE rules, these three are enabled by default with a Log action. The reason is that the request patterns they detect can also appear in legitimate traffic. Blocking them immediately could disrupt your application. You should review matching requests in Security Events and change the action to Block only after confirming they do not impact valid user activity.
Actionable Steps for Developers
A WAF is a compensating control, not a replacement for patching. Exploits can reach vulnerabilities through paths a WAF does not see, such as internal network traffic or specific server configurations. The only complete fix is upgrading your runtime.
1. Upgrade PHP and Ruby Immediately
- PHP: Upgrade to versions 8.2.36, 8.3.37, 8.4.28, 8.5.13, or 8.6.0. Remember to restart all PHP workers to ensure the new binary is in use.
- Ruby: Upgrade to versions 3.3.14, 3.4.13, or 4.0.10. If you use Docker, ensure your base image is rebuilt with the new Ruby version. Note that Ruby 3.2 and earlier are end-of-life and will not receive these fixes.
2. Review String Handling in Ruby
If you cannot patch Ruby immediately, consider these temporary mitigations:
- Ensure all incoming data is treated as UTF-8.
- Avoid using
upcase,swapcase,downcase(:fold), orcasecmp?on strings with legacy single-byte encodings. - If you use Rails or Sinatra, be aware that the default
MethodOverridemiddleware is a primary vector for this vulnerability. While you cannot easily disable this without breaking standard RESTful routing, understanding this risk helps you prioritize patching.
3. Monitor WAF Logs
Regularly check your Cloudflare dashboard for security events:
- Blocked Requests: Look for rule IDs associated with PHP RCE and ruby2shell. A high volume of blocked requests may indicate active scanning or attack attempts against your applications.
- Logged Requests: Review events from the three new PHP-FPM and SOAP rules (if on a paid plan). If you see legitimate traffic being logged, adjust your application to avoid these patterns or keep the action as Log until you are confident in the safety of blocking.
4. Verify Distribution Packages
Linux distributions often backport security fixes without changing the major version number. Check your package manager’s advisory for the specific CVE IDs (CVE-2026-126714, CVE-2026-132825) to ensure your system packages are updated, even if the version number appears unchanged.
Best Practices for WAF Implementation
While Cloudflare’s managed rulesets handle much of the heavy lifting, effective WAF usage requires more than just enabling defaults.
Treat WAF as a Layer, Not a Shield
A WAF inspects HTTP traffic at the edge. It cannot protect against:
- Internal lateral movement within your network.
- Vulnerabilities triggered by non-HTTP protocols.
- Logic flaws that do not involve malicious input patterns detectable at the network edge.
Always assume that a WAF rule might miss a novel exploit variant. Patching is the only way to eliminate the vulnerability itself.
Regularly Review Rule Actions
Cloudflare updates rules frequently. A rule set to Log today might be set to Block tomorrow if the pattern becomes more clearly malicious. Conversely, a rule that blocks legitimate traffic should be adjusted. Make it a habit to review Security Events weekly, especially after major vulnerability disclosures, to ensure your WAF configuration remains optimal.
Test in Staging
Before changing a rule from Log to Block in production, test it thoroughly in a staging environment. This is particularly important for rules like the new PHP-FPM and SOAP rules, which have a higher risk of false positives.
Keep Your Stack Updated
The vulnerabilities discussed here are in core language runtimes. This means that any application built on PHP or Ruby is potentially affected, regardless of the framework. Automate your dependency updates and monitor security advisories from the PHP and Ruby projects to stay ahead of new threats.
Key Takeaways
- Immediate Protection: Cloudflare WAF blocks known attack patterns for phpAfterShell (CVE-2026-126714) and ruby2shell (CVE-2026-132825) for all customers, including the Free plan.
- Patching is Mandatory: WAF rules are a compensating control. You must upgrade PHP to versions 8.2.36+ or 8.3.37+ and Ruby to versions 3.3.14+, 3.4.13+, or 4.0.10+ to fully eliminate the risk.
- New Rules for Paid Plans: Three new rules for PHP-FPM and SOAP flaws are enabled in Log mode by default. Review these carefully before switching to Block to avoid disrupting legitimate traffic.
- Default Configs are Vulnerable: Ruby on Rails and classic Sinatra apps are exposed to ruby2shell by default due to Rack’s
MethodOverridemiddleware. - Monitor and Adjust: Regularly review WAF logs to catch emerging threats and adjust rule actions to prevent false positives.
FAQ
Does Cloudflare WAF protect against all PHP and Ruby vulnerabilities? No. The WAF blocks known attack patterns for specific CVEs. It does not protect against unknown vulnerabilities, logic flaws, or attacks that bypass HTTP inspection, such as internal network threats. Patching your runtime is always required for complete protection.
Why are some new rules set to "Log" instead of "Block"? Rules for PHP-FPM request smuggling and SOAP flaws detect patterns that can also appear in legitimate traffic. Setting them to "Log" allows you to monitor for false positives and adjust your application or rules before enforcing a block, preventing accidental downtime.
I use a self-hosted product like GitLab or Discourse. What should I do? Check the vendor’s security advisory. Many self-hosted products bundle their own version of PHP or Ruby. You may need to update the specific package or container image provided by the vendor to ensure you are running the patched runtime version.
How do I verify if my WAF is blocking these attacks? Go to the Cloudflare dashboard, navigate to Security > Events, and filter by the rule group for "PHP Remote Code Execution" or "Ruby String Case Conversion." You will see blocked requests if an attack was attempted. For rules in "Log" mode, you will see logged events instead.
About the Author
Suraj Kumar is a writer, entrepreneur, and the CEO and founder of this website, sharing simple and practical insights on business, creativity, and personal growth. With experience building digital projects, they enjoy helping others learn, grow, and succeed online.


