JupiteX Get the app
Science & Technology30 Nov 2026 · about 6 min

Critical RubyGems Flaw Could Have Let Any Gem Publisher Run Code on the Registry

The brief

RubyGems.org is the central registry for the Ruby community’s gems. A gem is a package of code that Ruby applications can use. A registry stores published packages and makes them available for people building or maintaining applications. It provides a shared place to find and download gems. The scale is substantial: RubyGems.org hosts about 199,000 gems and has counted more than 278 billion downloads. Publishing involves sending a gem and its metadata to the service. That metadata helps describe the gem, and the registry checks it before accepting an upload. A flaw in that checking process let a push-capable API key supply a dangerous regular-expression pattern in metadata. The hosted service has been fixed, and gem users do not need to take action. Operators running their own RubyGems.org software should update to a commit containing the fix. Ruby applications also need updated Ruby runtime versions to address separate flaws.

01

What is RubyGems.org, and what does a gem registry do?

RubyGems.org is the central registry for the Ruby community’s gems. A gem is a package of code that Ruby applications can use. A registry stores published packages and makes them available for people building or maintaining applications. It provides a shared place to find and download gems.

The scale is substantial: RubyGems.org hosts about 199,000 gems and has counted more than 278 billion downloads. Publishing involves sending a gem and its metadata to the service. That metadata helps describe the gem, and the registry checks it before accepting an upload.

A flaw in that checking process let a push-capable API key supply a dangerous regular-expression pattern in metadata. The hosted service has been fixed, and gem users do not need to take action. Operators running their own RubyGems.org software should update to a commit containing the fix. Ruby applications also need updated Ruby runtime versions to address separate flaws.

02

How did a YAML tag let an uploaded gem’s metadata pass validation and reach Ruby’s regular-expression compiler?

A gem upload can carry metadata written as YAML, a format used to represent structured information. RubyGems.org validates that metadata before processing it. The flaw was that its validator did not recognize the YAML tag !ruby/regexp, so a field with that tag passed schema checks as if it were ordinary text.

After the check, Ruby’s YAML library, Psych, interpreted the tagged field as a regular expression. It compiled the pattern supplied by the attacker. This meant the pattern was not merely stored as text: it reached Ruby’s regexp compiler as an active expression during upload processing.

The order mattered. This processing happened before RubyGems.org checked whether the account owned the gem name. So an attacker with a push-capable API key could submit the crafted metadata without owning a gem under that name. The registry now rejects regexp-tagged gemspec fields during schema validation and uses a restricted YAML loader.

03

Why was a push-capable API key enough to trigger the flaw, even if the attacker did not own the gem name?

A push-capable API key can submit gem uploads to RubyGems.org. The flaw was in the handling of metadata attached to an upload, not in a check that required the uploader to own the gem name. The registry processed the metadata before it performed that ownership check.

An attacker could put a !ruby/regexp YAML tag in a metadata field. The validator treated the tagged value as plain text and let it pass. Then Psych, Ruby’s YAML library, turned the value into a regular expression and Ruby compiled the attacker’s pattern. The attacker therefore needed an API key with upload capability, but did not need a gem of their own.

That order of operations made the flaw especially concerning: the upload process reached dangerous code before the registry established that the account was entitled to publish under the chosen name. The hosted registry now rejects regexp-tagged gemspec fields with an HTTP 422 error. The advisory says gem users need do nothing; self-hosted operators should update.

04

What did the maintainers demonstrate an attacker could do, and what evidence is there about actual exploitation?

The registry’s maintainers demonstrated that the flaw could be chained with a memory corruption bug in Ruby’s regular-expression compiler. In their local test, that combination reached remote code execution. The code ran with the privileges of the gem-upload worker in that local environment; the advisory does not identify which memory corruption bug was used.

Investigators reviewed production telemetry and 29,100 gems published between October 5 and November 4. They found no direct evidence that the flaw had been exploited in that period. That result is not proof that no attempt ever happened: logs were not retained long enough, and upload payloads were not recorded.

The advisory also does not say whether an attacker who achieved code execution could have reached published gems or publishing credentials. The hosted registry has been fixed, and gem users do not need to act. Separate flaws in Ruby’s regexp engine and string case conversion were patched in Ruby 4.0.10, 3.4.13, and 3.3.14.

05

How widely used is RubyGems.org, and how many recent gem publications did investigators review?

RubyGems.org is a major shared service for Ruby packages. Its statistics page lists about 199,000 hosted gems and more than 278 billion downloads. Those figures show how many packages and downloads the registry supports, though they do not by themselves indicate whether the vulnerability was used.

To look for signs of exploitation, investigators reviewed production telemetry and 29,100 gems published from October 5 through November 4. The advisory reports no direct evidence of exploitation in that material. The review therefore covered a substantial set of recent publications, but its scope had limits.

Logs had not been kept long enough, and the service had not recorded upload payloads. As a result, investigators could not rule out earlier attempts. The vulnerability has been fixed on the hosted service. Gem users do not need to take action, while operators who self-host the RubyGems.org software should update to a commit containing the fix.

06

What changes now stop regexp-tagged metadata from being processed, and what other safeguards were added?

The main change stops the dangerous metadata at validation. RubyGems.org’s schema checks now reject gemspec fields carrying the !ruby/regexp tag and return an HTTP 422 error. That prevents the tagged value from passing as plain text and later reaching Psych as a regular expression.

The registry also reads gem metadata with a restricted YAML loader. It refuses YAML aliases and allows only the handful of classes used by a valid gemspec. These controls narrow what the loader will process, even if an unusual value appears in uploaded metadata. Patterns in OIDC access policies are capped at 255 characters before compilation as another safeguard.

The hosted service is fixed, and gem users need do nothing. The validation change appeared in the public code repository on November 4, three weeks before disclosure. Operators running the software themselves should update to a commit containing the fix. Ruby applications should separately install the patched runtime versions listed by the Ruby project.

07

What does it mean to compile a regular expression, and why can compiling an attacker-supplied pattern be dangerous even without code execution?

A regular expression is a pattern used to describe text to look for. Compiling one means Ruby processes the pattern and prepares it for use in matching. This step is different from simply storing the pattern as text: the compiler has to interpret its contents and create a usable representation.

In the RubyGems.org flaw, Psych converted a tagged YAML field into a real regular expression, and Ruby compiled the attacker-supplied pattern during upload processing. The maintainers demonstrated remote code execution by chaining the issue with a memory corruption bug in Ruby’s regexp compiler. The advisory does not identify which memory corruption bug they used.

Code execution is not the only risk. The article says that even on a Ruby build not vulnerable to code execution, compiling an attacker’s pattern can crash an upload worker or exhaust its memory. The registry now rejects regexp-tagged metadata, restricts YAML loading, and caps OIDC policy patterns at 255 characters.

This brief was written by AI from the original reporting and checked by other models. Names, figures and quotes come from the source; read it for full context.

Read more in the JupiteX app

Pulse is free. New stories every 4 hours, each one broken into the questions that explain it.

Or read more news on the web