AI Security AI安全 4h ago Updated 2h ago 更新于 2小时前 42

Critical Ruby on Rails Vulnerability in Attackers' Crosshairs Ruby on Rails 关键漏洞成为攻击者目标

CVE-2026-66066 ("KindaRails2Shell") is a critical RCE vulnerability (CVSS 9.5) in Ruby on Rails affecting applications using libvips for Active Storage image processing The exploit chains a file-type confusion between Rails (which trusts client-supplied content type) and libvips (which reads magic bytes), routing crafted files through libmatio to HDF5's External File List feature to read arbitrary server files Patched servers (8.1.3.1) block the libvips file read but still remain vulnerable to v CVE-2026-66066(CVSS 9.5)是Ruby on Rails的严重漏洞,可导致远程代码执行(RCE),被称为"KindaRails2Shell" 漏洞利用libvips与HDF5库之间的文件类型识别差异,实现任意文件读取和凭据窃取 官方补丁未能完全修复RCE风险,攻击者仍可通过Marshal反序列化执行代码 VulnCheck发现约7000个暴露的Rails实例易受攻击,漏洞已在野被利用

65
Hot 热度
60
Quality 质量
55
Impact 影响力

Analysis 深度分析

TL;DR

  • CVE-2026-66066 ("KindaRails2Shell") is a critical RCE vulnerability (CVSS 9.5) in Ruby on Rails affecting applications using libvips for Active Storage image processing
  • The exploit chains a file-type confusion between Rails (which trusts client-supplied content type) and libvips (which reads magic bytes), routing crafted files through libmatio to HDF5's External File List feature to read arbitrary server files
  • Patched servers (8.1.3.1) block the libvips file read but still remain vulnerable to variation-key Marshal deserialization RCE gadgets given a valid signature
  • VulnCheck reported ~7,000 exposed vulnerable Rails instances as of early August, with active exploitation beginning roughly one month post-patch disclosure
  • Attackers can leverage compromised secrets to forge sessions, perform lateral movement, and achieve full remote code execution

Why It Matters

This vulnerability demonstrates how subtle protocol-level mismatches between libraries can create devastating attack chains, and the incomplete nature of the initial patch highlights the importance of defense-in-depth in security remediation. For AI practitioners and developers using Ruby on Rails—especially those processing user-uploaded images—the flaw poses an immediate and serious risk of credential theft and remote code execution.

Technical Details

  • Root Cause: A two-layer file-type confusion between Rails and libvips. Rails trusts the client-supplied Content-Type header to interpret uploaded blobs as images, while libvips inspects magic bytes to determine the actual file format. This mismatch allows an attacker to declare a file as "MATLAB Level 5" while embedding MAT 7.3 headers that trigger the HDF5 loader.
  • Exploit Chain: Crafted file → declared as MATLAB Level 5 → libvips selects MATLAB loader → libmatio detects MAT 7.3 → hands off to HDF5 → HDF5's External File List feature reads attacker-specified file paths and offsets → file contents returned as image pixels.
  • Post-Patch Bypass: The 8.1.3.1 patch blocks the libvips-based arbitrary file read but does not address the variation-key Marshal deserialization gadget, meaning RCE remains possible on patched servers if the attacker possesses a valid Marshal signature.
  • Impact Scope: Affects any unauthenticated attacker targeting Rails applications that use libvips for Active Storage and accept image uploads from untrusted users. Compromised targets include credential databases and storage keys.
  • Detection: Rails published forensic tools to help identify exploitation attempts; VulnCheck identified approximately 7,000 exposed vulnerable instances in early August.

Industry Insight

  • Organizations using Ruby on Rails with Active Storage and libvips should prioritize patching immediately and audit for any remaining Marshal deserialization attack surfaces, as the initial patch is incomplete.
  • This case reinforces the need for defense-in-depth: relying on a single-layer fix is insufficient when chained vulnerabilities exist across library boundaries. Security teams should conduct thorough penetration testing post-patch.
  • The ~1-month gap between patch release and active exploitation, combined with 7,000 exposed instances, suggests many organizations are lagging in vulnerability management. Proactive monitoring and automated patch deployment should be standard practice for internet-facing Rails applications.

TL;DR

  • CVE-2026-66066(CVSS 9.5)是Ruby on Rails的严重漏洞,可导致远程代码执行(RCE),被称为"KindaRails2Shell"
  • 漏洞利用libvips与HDF5库之间的文件类型识别差异,实现任意文件读取和凭据窃取
  • 官方补丁未能完全修复RCE风险,攻击者仍可通过Marshal反序列化执行代码
  • VulnCheck发现约7000个暴露的Rails实例易受攻击,漏洞已在野被利用

为什么值得看

这篇报道揭示了关键Web框架中的严重安全漏洞,对使用Ruby on Rails的开发者和企业具有直接威胁。补丁的局限性提醒安全团队需要持续验证防护措施的有效性,不能盲目依赖单一修复。

技术解析

  • 漏洞核心在于Rails依赖客户端提供的content type判断文件类型,而libvips通过magic bytes识别文件类型,这种不一致性被攻击者利用
  • 攻击者构造恶意文件声明为MATLAB Level 5格式,libvips选择MATLAB加载器,随后libmatio识别MAT 7.3并传递给HDF5
  • HDF5的External File List功能允许数据集字节存储在另一个文件中,通过路径和偏移量指定,使"图像"渲染实际读取服务器上的任意文件
  • 补丁虽然阻止了libvips的文件读取,但未能修复variation-key Marshal反序列化问题,RCE gadget在拥有有效签名的情况下仍可执行

行业启示

  • 第三方库依赖链中的安全漏洞可能产生连锁反应,需要全面审查依赖关系和潜在攻击面
  • 安全补丁发布后应持续监控和验证,确保修复措施真正有效,不能盲目依赖单一补丁
  • 对暴露在互联网上的服务进行定期安全审计和漏洞扫描至关重要,尤其是涉及文件上传和处理的功能

Disclaimer: The above content is generated by AI and is for reference only. 免责声明:以上内容由 AI 生成,仅供参考。

Security 安全 Programming 编程