Tuesday 1 December 2026 Edition compiled at 07.38 NL EN FR
← Tech · Programming languages
Tech · Programming languagesRuby

A regular expression hidden in a gem's metadata: any publishing key could run code on RubyGems.org's servers

Ruby's package registry has closed the hole and found no direct evidence of abuse among 29,100 recent gems, but cannot rule out earlier attempts.

· latest source update ma · 2 sources · The Hacker News, Cyber Security News · Compiled with AI
Illustration for this article

RubyGems.org, Ruby's package registry, has fixed a critical flaw that let anyone with an API key allowed to publish gems run code on the servers that process uploads, The Hacker News reports. Advisory GHSA-7h7w-m82c-x2xg was published on 26 November and carries a score of 9.0; there is no CVE number. The attacker did not need to own a gem, because the metadata was processed before the registry checked whether the account owned the package name.

At the heart of the problem, the validation treated a field carrying the YAML tag !ruby/regexp as plain text, while the Psych parser turned it into a real regular expression, Cyber Security News writes. In a local test on Ruby 4.0.9 the maintainers combined this with a memory bug in Ruby's regex compiler, which led to code execution with the privileges of the upload process. Even on a Ruby version without that memory bug, such a pattern could crash an upload worker or exhaust its memory. On 18 November Ruby fixed seven flaws in regular expressions and case conversion, in versions 4.0.10, 3.4.13 and 3.3.14.

The maintainers reviewed telemetry and the 29,100 gems published between 5 October and 4 November and found no direct evidence of exploitation. They cannot rule out earlier attempts, because logs were not kept long enough and upload contents were not recorded. Gem users need not do anything; anyone running their own copy of the registry software must update to a commit containing the fix. The registry hosts about 199,000 gems with more than 278 billion downloads.

Spotted a mistake in this article? Let us know.