Cloudflare WAF 如何防护 ruby2shell 漏洞(CVE-2026-132825)
2026 年 11 月 19 日,Ruby 团队披露了 ruby2shell(CVE-2026-132825),这是 Ruby 字符串大小写转换中的一个严重堆缓冲区溢出漏洞,修复版本为 Ruby 3.3.14、3.4.13 和 4.0.10。Cloudflare WAF 现已为包括免费套餐在内的所有客户拦截该漏洞,通过在托管规则集中新增两条规则,分别覆盖 ruby2shell 和相关的整数溢出漏洞 GHSA-87fm-7w84-j2px。
该漏洞的成因是:在 ISO-8859-1、Windows-1252 等 14 种传统单字节编码中,Ruby 对德语 sharp s(ß)转大写时会写入两个字节,却只检查了一个字节的空间;受影响的方法包括 upcase、swapcase、downcase(:fold) 和 casecmp?,UTF-8 字符串不受影响。Rails 和经典风格的 Sinatra 应用默认即受影响,因为 Rack 的 MethodOverride 中间件会在路由阶段对 _method 参数转大写,此时尚未经过任何身份验证。受影响版本为 Ruby 3.3.13 及更早版本、3.4.0 至 3.4.12 以及 4.0.0 至 4.0.9,GitLab、GitHub Enterprise Server、Mastodon、OpenProject、Discourse 和 Chatwoot 等自托管产品在披露时都捆绑了受影响的 Ruby。
Cloudflare 强调 WAF 只是一种补偿性控制措施:攻击可以通过绕过 Cloudflare 的流量或电子邮件、文件导入、后台任务等非 HTTP 路径到达,因此升级 Ruby 才是唯一完整的修复。同一批 Ruby 版本还修复了另外六个内存安全漏洞,其中五个位于正则表达式引擎中。
由于公开的概念验证预计将在数日内出现,文章敦促团队检查 WAF 覆盖情况、升级 Ruby 并重启所有进程、重建容器镜像、迁移出 Ruby 3.2 及更早版本,并及时更新捆绑 Ruby 的产品,例如 Discourse 的 Docker 基础镜像已切换到 Ruby 4.0.10。Cloudflare 表示已修补自身使用 Ruby 的系统,未发现被入侵的迹象。
How Cloudflare WAF protects against ruby2shell (CVE-2026-132825)
On November 19, 2026, the Ruby team disclosed ruby2shell (CVE-2026-132825), a Critical heap buffer overflow in Ruby's string case conversion, with fixes in Ruby 3.3.14, 3.4.13, and 4.0.10. Cloudflare WAF now blocks the flaw for all customers, including the Free plan, via two new rules in its managed rulesets that cover ruby2shell and a related integer overflow, GHSA-87fm-7w84-j2px.
The bug arises because in 14 legacy single-byte encodings such as ISO-8859-1 and Windows-1252, Ruby writes two bytes when upcasing the German sharp s (ß) but checks for room for only one; the methods upcase, swapcase, downcase(:fold) and casecmp? are affected, while UTF-8 strings are not. Rails and classic-style Sinatra apps are exposed by default because Rack's MethodOverride middleware upcases the _method parameter during routing, before any authentication. Affected versions are Ruby 3.3.13 and earlier, 3.4.0 through 3.4.12, and 4.0.0 through 4.0.9, and self-hosted products including GitLab, GitHub Enterprise Server, Mastodon, OpenProject, Discourse and Chatwoot bundled an affected Ruby at disclosure.
Cloudflare stresses the WAF is only a compensating control: exploits can arrive via traffic that bypasses Cloudflare or through non-HTTP paths such as email, file imports and background jobs, so upgrading Ruby is the only complete fix. The same Ruby releases also fix six other memory safety flaws, five of them in the regex engine.
With a public proof of concept expected within days, the post urges teams to check WAF coverage, upgrade Ruby and restart all processes, rebuild container images, move off Ruby 3.2 or earlier, and update bundled products such as Discourse, whose Docker base image already moved to Ruby 4.0.10. Cloudflare says it has patched its own Ruby systems and found no indication of compromise.
猎鹰不保存原文正文。标题与摘要用于快速发现信息,事实细节请以来源原文为准。