Skip to content
eastbaycyber

RubyGems.org fixes critical gem-push validation flaw

Breaking news 6 min read
EC
East Bay Cyber Editorial Team Updated Developing story
Built from the vendor or authority notice plus independent reporting; unconfirmed claims are labeled as reported. Human-reviewed after publishing.

TL;DR - Update: RubyGems.org’s advisory now documents the fix details, including restricted YAML loading, HTTP 422 rejection of regexp-tagged fields, and a 255-character limit for OIDC access-policy patterns. - An authenticated account with a push-capable API key could submit crafted metadata without owning the gem name. - Local testing on Ruby 4.0.9 reached remote code execution by chaining the issue with a memory corruption bug in Ruby’s regexp compiler. - RubyGems.org found no direct evidence of exploitation in a review covering 29,100 gems, but retention gaps mean earlier attempts cannot be ruled out. - Hosted-service users do not need to take action. Self-hosted operators should update to a commit containing the fix.

What happened#

RubyGems.org’s gem-push validator ignored the !ruby/regexp YAML tag during schema validation. A gemspec field carrying the tag could therefore pass validation as an untagged scalar. Psych, Ruby’s YAML library, later deserialized the field into a regular expression and compiled the attacker-controlled pattern.

The vulnerable processing occurred when crafted metadata was submitted to POST /api/v1/gems. Validation and deserialization ran before the registry checked whether the account owned the gem name. According to the RubyGems.org security advisory, an attacker needed a RubyGems.org account and a push-capable API key, but did not need ownership of an existing gem.

On Ruby 4.0.9, crafted gemspec patterns achieved remote code execution with the privileges of the gem-upload worker process in local testing. The test was reproduced locally rather than against the live service. Even on Ruby builds not vulnerable to code execution, attacker-controlled regexp compilation could crash an upload worker or exhaust its memory.

RubyGems.org rates the issue as Critical and gives it a CVSS overall score of 9.0. It is tracked as GHSA-7h7w-m82c-x2xg. No CVE has been assigned in the available advisories.

The fix removes !ruby/regexp from GemValidator::NodeInfo::IGNORED_TAGS, so schema validation rejects regexp-tagged gemspec fields before deserialization and returns HTTP 422. RubyGems.org also replaced unrestricted to_ruby calls with safe_to_ruby, which uses restricted Psych loading, refuses YAML aliases, disallows Ruby classes in checksums.yaml, and allows only the classes used by a valid gemspec. As additional protection, OIDC access-policy string_matches patterns are capped at 255 characters before compilation.

Are you affected#

The hosted RubyGems.org service is the registry described in the advisory. RubyGems.org states that gem users do not need to take action because it is a hosted service.

Operators running a self-hosted RubyGems.org deployment are affected if their deployment does not contain the fix. The advisory recommends updating to a commit containing the fix.

The issue concerns registry processing of gem uploads. It does not establish that every gem hosted on RubyGems.org is malicious or affected. The advisory lists the affected version as -1 and the patched version as None, rather than identifying a conventional vulnerable or fixed software version.

The RubyGems.org statistics page lists 199,355 total gems and 279,014,566,848 total downloads. These figures describe the registry’s overall scale and do not indicate exploitation of this issue.

Ruby applications also have separate runtime flaws. The Hacker News reports that those flaws are fixed in Ruby 4.0.10, 3.4.13 and 3.3.14. The RubyGems.org advisory does not state that those runtime versions are required for the registry-side fix.

What is confirmed and what is reported#

Claim Source Status
RubyGems.org’s validator ignored the !ruby/regexp YAML tag and later deserialized it into an attacker-controlled regular expression. RubyGems.org security advisory Confirmed
An authenticated user with a push-capable API key could reach the vulnerable upload path without owning an existing gem. RubyGems.org security advisory Confirmed
Local testing on Ruby 4.0.9 reached remote code execution by chaining the issue with a memory corruption bug in Ruby’s regexp compiler. RubyGems.org security advisory Confirmed
The code-execution test ran locally against Ruby 4.0.9 rather than against the live service. RubyGems.org security advisory Confirmed
A review of production telemetry and 29,100 gems published between 5 October and 4 November 2026 found no direct evidence of exploitation. RubyGems.org security advisory Confirmed
Log-retention gaps and unlogged upload payloads mean earlier attempts cannot be ruled out. RubyGems.org security advisory Confirmed
Regexp-tagged gemspec fields are now rejected with HTTP 422, unrestricted deserialization was replaced with restricted loading, and OIDC access-policy patterns are capped at 255 characters. RubyGems.org security advisory Confirmed
The issue has no CVE assigned and has a CVSS score of 9.0. RubyGems.org security advisory Confirmed
The validation change entered RubyGems.org’s public code repository on November 4 (UTC), before disclosure. The Hacker News Reported
Ruby applications have separate runtime flaws fixed in Ruby 4.0.10, 3.4.13 and 3.3.14. The Hacker News Reported
The advisory does not say whether code execution could provide access to published gems or publishing credentials. The Hacker News Reported

What defenders should do now#

  1. If using the hosted RubyGems.org service to install or publish gems, note RubyGems.org’s guidance that gem users do not need to take action for this registry-side issue.

  2. If operating a self-hosted RubyGems.org deployment, update to a commit containing the fix, as recommended in the RubyGems.org security advisory.

  3. Review registry telemetry and available upload records for unusual gem-push activity. Account for the advisory’s statement that log-retention limits and unlogged upload payloads prevent definitive conclusions about earlier attempts.

  4. Review accounts and API keys with push capability. The vulnerability required an account with a push-capable API key.

  5. Consider whether any local Ruby applications require the separate Ruby runtime updates reported by The Hacker News: Ruby 4.0.10, 3.4.13 and 3.3.14. Treat that maintenance separately from the RubyGems.org registry fix.

  6. For incident review, distinguish the local code-execution demonstration from evidence of compromise of the live hosted service. RubyGems.org reported no direct evidence of exploitation in its review, while also noting that earlier attempts cannot be ruled out.

This advisory is informational and is updated as vendors publish details. Confirm versions and actions against the vendor’s own guidance for your environment.

Sources

Last verified: 2026-12-02

Disclaimer: This article may contain affiliate links. We earn a commission on qualifying purchases at no extra cost to you.