VMTech
Discuss a project →

RubyGems closes critical YAML flaw in gem upload processing

RubyGems closes critical YAML flaw in gem upload processing

RubyGems.org has fixed a critical vulnerability, tracked as GHSA-7h7w-m82c-x2xg and rated 9.0 under CVSS, that could have allowed any account holding a push-capable API key to execute code on the registry’s gem-upload worker. The maintainers demonstrated the chain locally on Ruby 4.0.9 by combining the registry flaw with a memory-corruption bug in Ruby’s regular-expression compiler.

Gem users do not need to take action because the hosted registry has been fixed. A review of production telemetry and 29,100 gems published between October 5 and November 4 found no direct evidence of exploitation. However, RubyGems.org said that limited log retention and the absence of recorded upload payloads mean earlier attempts cannot be definitively excluded.

YAML metadata bypassed validation

The flaw lay in the way RubyGems.org processed gem metadata supplied as YAML. Its validator did not account for the !ruby/regexp YAML tag, allowing a tagged field to pass schema validation as ordinary text. Ruby’s YAML library, Psych, subsequently materialised that value as a regular expression and compiled the pattern controlled by the uploader.

Critically, this processing happened before the registry verified that the uploader owned the gem name. An attacker therefore did not need to control or publish a gem; a push-capable API key was sufficient to reach the affected upload path.

The advisory does not identify which Ruby memory-corruption issue was used in the local proof of concept. It notes that, even where the Ruby runtime could not be driven to code execution, compilation of an attacker-supplied pattern could still crash an upload worker or consume its memory.

Hosted service patched; self-hosted operators must update

RubyGems.org now rejects regexp-tagged gemspec fields with an HTTP 422 response. The registry has also moved metadata handling to a restricted YAML loader that refuses aliases and permits only the limited set of classes needed by a valid gemspec. As an additional control, patterns used in OIDC access policies are capped at 255 characters before compilation.

Commit history shows the validation change entered the public RubyGems.org repository on November 4 UTC, roughly three weeks before disclosure. The registry hosts about 199,000 gems and has recorded more than 278 billion downloads, making the upload pipeline an important supply-chain boundary for the Ruby ecosystem.

Different actions for registry and application operators

Operators running self-hosted RubyGems.org software should update to a commit containing the registry fix. Ruby applications have a separate maintenance requirement: the seven runtime issues affecting Ruby’s regexp engine and string case conversion are fixed in Ruby 4.0.10, 3.4.13 and 3.3.14.

The tested code execution ran with the privileges of the gem-upload worker, and the advisory does not establish whether that access could have reached publishing credentials or published gems. For businesses operating Ruby package infrastructure, the practical priority is to patch self-hosted registries, update affected Ruby runtimes, and treat metadata parsing before authorization as a security-critical boundary.

#rubygems#rubysecurity#appsec#supplychain
Open analytics
On the site 2 views
min read 4 30.11.2026
Instagram

RubyGems closes critical YAML flaw in gem upload processing

Open the post on Instagram ↗