Skip to content

Ruby patches 7 String and Regexp memory bugs, RCE possible

Ruby 4.0.10, 3.4.13 and 3.3.14 fix seven String and Regexp memory-safety flaws, including a heap overflow in case conversion dubbed Ruby2Shell. RCE is possible but hard; patch now.

Published 3 min read

The Ruby core team shipped Ruby 4.0.10, 3.4.13 and 3.3.14 on November 18 to fix seven memory-safety flaws in the String and Regexp engines, several of which "may allow remote code execution." The standout — nicknamed Ruby2Shell in SecurityWeek's writeup — is a one-byte heap overflow during string case conversion that an unauthenticated attacker may be able to reach through common web frameworks. The primary source is Ruby's advisory, Multiple vulnerabilities in Regexp and String.

The flaws

Ruby's advisory lists the seven bugs by GitHub Security Advisory ID. Per the advisory, CVE identifiers "have been requested... but have not been assigned yet" — so despite secondary coverage citing a CVE for Ruby2Shell, the official advisory carries no CVE numbers at the time of writing. The GHSA IDs:

  • GHSA-34m4-m9fh-gqp5 — heap buffer overflow in string case conversion (the "Ruby2Shell" bug; one-byte overflow, possible RCE).
  • GHSA-87fm-7w84-j2px — integer overflow in string case conversion leading to a heap overflow (possible RCE).
  • GHSA-7x2q-68qv-6p8x — double free in Regexp compilation (possible RCE when compiling attacker-controlled patterns).
  • GHSA-3p8q-wmhx-vm2w — integer overflow in Regexp compilation leading to a heap overflow (possible RCE).
  • GHSA-7whj-cfh7-xgm4 — heap buffer overflow in Regexp#to_s (info disclosure or RCE).
  • GHSA-wpqw-5qxg-m68r — out-of-bounds read in case-insensitive Regexp matching (memory corruption).
  • GHSA-pvgc-g7gj-pv6h — out-of-bounds read in case-insensitive backreference matching (memory disclosure or crash).

The case-conversion overflow fires on single-byte encodings such as ISO-8859-1 and Windows-1252: upcasing "ß" yields "SS," two bytes where Ruby reserved one. Veria Labs reports that in default configurations, unauthenticated attackers could reach it through Rails and classic-style Sinatra; WatchTowr adds that any Ruby app that changes the case of externally supplied text in a single-byte encoding is exposed, and names GitHub Enterprise Server as affected.

Affected and fixed versions

Vulnerable: Ruby 3.3.13 and earlier, 3.4.0 through 3.4.12, and 4.0.0 through 4.0.9. Fixed in 4.0.10, 3.4.13 and 3.3.14 — the advisory's exact recommendation is to upgrade to one of those. Chatwoot, GitLab, Mastodon, OpenProject and the Discourse base image have already shipped patched builds.

Exploitation status

No in-the-wild exploitation is reported. WatchTowr assesses that reliable RCE in production would be hard — it needs memory-layout grooming, specific allocator conditions, and an ASLR defeat — and that the most likely outcome of a malformed request is a denial of service. Veria Labs says it will release a proof of concept after major vendors patch.

Action checklist

  1. Upgrade the Ruby runtime to 4.0.10, 3.4.13 or 3.3.14 across app servers, CI images and base containers — this is an interpreter fix, not a gem bump.
  2. Update affected downstream apps (GitLab, Mastodon, Discourse, OpenProject, Chatwoot) to their patched releases.
  3. If you can't patch immediately, audit where external input hits case conversion (upcase/downcase) on non-UTF-8 strings or compiles attacker-controlled regexes, and treat those paths as DoS-exposed.
  4. Watch for the forthcoming Veria Labs PoC and plan to have the runtime patched before it lands.

Context

This is the second Ruby memory-safety batch in as many months: October's release fixed four Onigmo regex-engine bugs behind a set of GitLab CVEs (our coverage here). The String and Regexp parsers remain a productive hunting ground, and the recurring theme — unauthenticated input reaching a C-level parser through a web framework — is why these land as "patch the interpreter now," not "a library you might not use."

Related stories