RubyGems flaw could have let gem publishers run code on the registry
RubyGems.org fixed a critical upload flaw that could have turned crafted gem metadata into code execution in local testing.
RubyGems.org has fixed a critical flaw that could have let any account with a push-capable API key pass an attacker-controlled regular expression into the registry's gem-upload pipeline, according to The Hacker News and the linked RubyGems.org advisory.12
The issue was in how the registry handled YAML metadata attached to a gem. Its validator did not reject the `!ruby/regexp` tag, allowing a field that looked like text during schema checks to become a real regular expression when Ruby's Psych YAML library loaded it. The pattern was compiled before the registry checked whether the account owned the gem name, so an attacker needed a push-capable key rather than control of a particular gem.12
RubyGems maintainers said they chained the upload flaw with a memory-corruption bug in Ruby's regular-expression engine during local testing. That reached code execution with the privileges of the gem-upload worker. The report does not establish that the hosted service was exploited: a review of production telemetry and 29,100 gems published between October 5 and November 4 found no direct evidence, although incomplete log retention meant earlier attempts could not be ruled out.1
The issue is tracked as GHSA-7h7w-m82c-x2xg and carries a CVSS score of 9.0. RubyGems.org now rejects regexp-tagged gemspec fields with HTTP 422, uses a restricted YAML loader, and limits patterns in OIDC access policies to 255 characters.2 Ruby's separate runtime fixes are listed in its 18 November security announcement; the report says Ruby 4.0.10, 3.4.13 and 3.3.14 contain those patches.3
What users and operators need to know
RubyGems users do not need to change anything for the hosted registry, according to the report. Operators running RubyGems.org software should update to a revision containing the fix. Ruby application maintainers should also apply the relevant Ruby runtime updates rather than treating the registry patch as a substitute for them.13
The incident matters because it shows how a seemingly narrow metadata-validation gap can become a server-side execution risk when deserialisation and compilation happen inside a privileged upload service. The important distinction is that the demonstrated chain was local testing, not proof of a live compromise.
Our opinion
This is a strong example of why package registries should treat metadata as hostile input all the way through processing, not merely validate its surface shape. RubyGems' layered response is the right direction: reject the dangerous tag, restrict what the loader can construct, and cap inputs before compilation. The lack of direct evidence of exploitation is reassuring, but the telemetry gaps are a reason for operators to patch promptly rather than wait for a cleaner post-mortem.12
Photo by Mikhail Nilov on Pexels, used as a generic cybersecurity illustration.4