CriticalVulnerabilityPatch available

RubyGems.org upload flaw allows registry code execution via YAML

RubyGems.org fixed a critical gem upload flaw (GHSA-7h7w-m82c-x2xg) that could run code on the registry; self-hosters should update.

Published
Fixed in
Fix is in the RubyGems.org code, not a gem release. Self-hosted deployments need a commit containing the fix (commit id not confirmed). Hosted service already fixed.
Exploitation
No direct evidence of exploitation in 29,100 gems reviewed (October 5 to November 4, 2026), but earlier attempts cannot be ruled out. Code execution was shown only in local testing on Ruby 4.0.9.

What happened

The RubyGems.org maintainers published GitHub security advisory GHSA-7h7w-m82c-x2xg on November 26, 2026, rated Critical with a CVSS v4 score of 9.0. The advisory lists no known CVE, and the weakness is classed as CWE-502, deserialization of untrusted data (GitHub: RubyGems.org advisory).

According to the advisory, the gem-push validator ignored the !ruby/regexp YAML tag during schema validation. Ruby’s YAML library, Psych, then turned that field into a real regular expression and compiled the attacker-supplied pattern. A gemspec field such as summary carrying the tag therefore passed validation as plain text (GitHub: RubyGems.org advisory).

This happened before the registry checked who owned the gem name. An attacker needed only a RubyGems.org account and a push-capable API key, not ownership of any existing gem (GitHub: RubyGems.org advisory, Cyber Security News).

Impact, as reported:

  • Code execution: On Ruby 4.0.9, the maintainers chained the flaw with a memory corruption bug in Ruby’s regexp compiler. This gave code execution with the privileges of the gem-upload worker, in local testing only. It was not reproduced against the live service (GitHub: RubyGems.org advisory, GBHackers).
  • Crashes and memory use: Even on Ruby builds not vulnerable to code execution, compiling an attacker’s pattern can crash an upload worker or exhaust its memory (GitHub: RubyGems.org advisory).
  • Which memory bug: The Hacker News notes that the advisory does not say which memory corruption bug the chain used (The Hacker News).
  • Reach beyond the worker: The same outlet says the advisory does not state whether an attacker who got that far could have reached published gems or publishing credentials. This is not confirmed.

Exploitation status: the maintainers reviewed production telemetry and 29,100 gems published between October 5 and November 4, 2026, and found no direct evidence of exploitation. They say earlier attempts cannot be ruled out, because log retention was limited and upload payloads were not logged (GitHub: RubyGems.org advisory, The Hacker News).

The fix, per the advisory:

  • Schema validation now rejects regexp-tagged gemspec fields and returns HTTP 422.
  • Gem metadata is read with a restricted loader that refuses YAML aliases, disallows Ruby classes in checksums.yaml, and allows only the classes a valid gemspec uses.
  • Patterns in OIDC access policies are capped at 255 characters before compilation, as defence in depth (GitHub: RubyGems.org advisory).

The Hacker News adds that, per the commit history, the validation change entered the public code repository on November 4 (UTC), three weeks before disclosure (The Hacker News). The flaw affects server-side upload processing, not gem installation on developer machines (GBHackers).

Am I affected?

  • Gem users and publishers on the hosted RubyGems.org: No action is needed. The advisory says gem users do not need to take action because the hosted service is fixed (GitHub: RubyGems.org advisory).
  • Operators of a self-hosted RubyGems.org deployment: You are affected until you run a revision that contains the fix. The advisory lists no patched gem release, so updating an application’s dependencies will not apply the fix (GitHub: RubyGems.org advisory, GBHackers).
  • Ruby runtime versions: The Hacker News reports that the maintainers’ test ran on Ruby 4.0.9, which is affected by seven Ruby regexp engine and string case conversion flaws patched on November 18. It lists the fixes as Ruby 4.0.10, 3.4.13 and 3.3.14 (The Hacker News). Which of those flaws the chain used is not confirmed.

What to do now

  1. If you only consume or publish gems on the hosted RubyGems.org, no change is required.
  2. If you self-host the RubyGems.org software, update to a code revision that contains the fix. The specific commit id is not confirmed in the sources, so check the repository’s history for the validation change that removes !ruby/regexp from the ignored tags.
  3. Check which Ruby version your self-hosted upload workers run, and consider updating to a release that includes the November 18 fixes (4.0.10, 3.4.13 or 3.3.14, per The Hacker News).
  4. Be aware that your own logs may not show past attempts, since upload payloads are not logged by default in the hosted service. Whether the self-hosted software logs them is not confirmed.

Sources