RubyGems.org fixes upload flaw enabling code execution in tests

RubyGems.org fixes upload flaw enabling code execution in tests

Add CyberWorldOpsto your preferred sources on Google
RubyGems.org fixes upload flaw enabling code execution in tests
Vulnerabilities

Illustrative image generated with AI

RubyGems.org has fixed a critical upload-validation flaw that its maintainers chained with a Ruby memory corruption bug to execute code in local testing. In a security advisory published November 26, the maintainers said the hosted registry is patched and gem users need take no action; organizations running their own deployment of the RubyGems.org software should update.

The vulnerability, tracked as GHSA-7h7w-m82c-x2xg, required an account and an API key authorized to upload gems, Ruby’s software packages. An attacker did not need to own a gem because the vulnerable processing happened before the registry checked ownership of the package name. The advisory rates the flaw critical, with a Common Vulnerability Scoring System version 4 score of 9.0, and lists no assigned CVE identifier.

Maintainers reviewed production telemetry and 29,100 gems published between October 5 and November 4, 2026, finding no direct evidence of exploitation, though limited log retention and the absence of recorded upload payloads mean earlier attempts cannot be ruled out.

How package metadata reached the compiler

The flaw lay in the registry’s handling of YAML, the structured text format used for gem metadata. When an account submitted a package to POST /api/v1/gems, the upload validator checked that metadata against a schema before converting it into Ruby objects.

That check ignored the !ruby/regexp tag. The tag tells Ruby’s YAML library, Psych, to create a regular expression—a pattern used to match text. A field such as summary: !ruby/regexp /.../ therefore passed validation as ordinary text, but the subsequent conversion created a Regexp object and compiled the attacker’s pattern.

The order of operations made the flaw reachable by any account with a push-capable API key. Metadata validation and conversion ran before the Pusher component checked whether the account owned the requested gem name.

On Ruby 4.0.9, maintainers combined this behavior with a memory corruption bug in Ruby’s regular-expression compiler and achieved remote code execution with the privileges of the gem-upload worker process. The demonstration ran locally. Even on Ruby builds that are not vulnerable to code execution, compiling attacker-controlled patterns can crash a worker or exhaust its memory.

The Hacker News reported that Ruby 4.0.9 was affected by seven flaws in Ruby’s regular-expression engine and string case conversion that the Ruby project patched on November 18. The registry advisory does not identify which memory corruption flaw enabled the demonstrated chain.

Validation and loading restrictions added

The registry now rejects regexp-tagged metadata before converting it to Ruby objects. An affected upload receives HTTP 422 with the error expected no tag, but got "!ruby/regexp" path: /summary.

Maintainers also replaced unrestricted conversion calls with safe_to_ruby, using a restricted class loader and a visitor that refuses YAML aliases, which let one part of a YAML document reference another. The loader disallows Ruby classes in checksums.yaml and permits only the classes needed for a valid gem specification, including its versions, dependencies, requirements and basic values.

A further safeguard limits string_matches patterns in OpenID Connect (OIDC) access policies to 255 characters before compilation. OIDC supports identity-based authentication; the length cap is intended to reduce the risk of exhausting the regular-expression compiler. During token exchange, regular-expression errors are now converted into access errors.

The Hacker News reported that the validation change entered the registry’s public code repository on November 4 UTC, about three weeks before disclosure. The registry hosts about 199,000 gems and has recorded more than 278 billion downloads, the outlet reported, citing its statistics page.

Operators who self-host the RubyGems.org software should update to a commit containing the fix, as the maintainers recommend. Ruby application operators have a separate runtime update to consider: The Hacker News, citing the Ruby project’s security announcement, lists Ruby 4.0.10, 3.4.13 and 3.3.14 as the releases fixing the seven runtime flaws. Users of the hosted RubyGems.org registry do not need to take action for the upload vulnerability.

Read next

Sources

Back to home

Latest Cybersecurity News

All cybersecurity news →