RubyGems.org Fixes Critical YAML Regex Flaw That Allowed Remote Code Execution on Registry Servers
RubyGems.org has patched a critical CVSS 9.0 YAML deserialization vulnerability (GHSA-7h7w-m82c-x2xg) that let any account with a push-capable API key compile arbitrary regular expressions on registry servers and achieve remote code execution when chained with a Ruby 4.0.9 memory corruption bug.
RubyGems.org, the central package registry for the Ruby programming community, has patched a critical deserialization vulnerability that could have allowed any user with a push-capable API key to execute arbitrary code on registry servers. The flaw was detailed in a security advisory covered by The Hacker News, Cyber Security News, and IT-Boltwise.
Tracked under GitHub Security Advisory GHSA-7h7w-m82c-x2xg with a CVSS 4.0 severity score of 9.0 out of 10 and no assigned CVE identifier, the vulnerability affected how the registry parsed YAML metadata inside uploaded gem packages. RubyGems.org hosts approximately 199,000 gems and has served more than 278 billion package downloads across the Ruby ecosystem.
Every Ruby package upload contains a specification file, known as a gemspec, that stores package metadata formatted as YAML. When a developer pushes a package to RubyGems.org, a schema validator inspects those metadata fields to verify that they contain expected data types before the upload proceeds.
YAML Regex Tag Bypassed Gemspec Schema Checks
However, the registry’s schema validator ignored the !ruby/regexp YAML tag. When an upload included that tag inside a text field, the validator treated the entry as harmless plain text and allowed it to pass. Next, Ruby’s Psych YAML parsing library processed the metadata and deserialized the tagged string into a live regular expression object, immediately compiling the attacker’s pattern.
Crucially, the YAML parsing and regular expression compilation took place before RubyGems.org verified whether the uploading account actually owned the target gem name. Because the ownership check happened too late, an attacker did not need to own an existing package. Any newly created RubyGems.org account holding a push-capable API key could trigger the parser without any user interaction.
Classified under MITRE CWE-502 as deserialization of untrusted data, the registry bug became far more dangerous when paired with defects in the underlying Ruby runtime. In local testing on Ruby 4.0.9, RubyGems.org maintainers chained the YAML regular expression injection with a memory corruption flaw in Ruby’s regexp compiler. That two-step chain achieved remote code execution with the privileges of the gem-upload worker process.
The local test relied on one of the seven regexp engine and string case conversion vulnerabilities that took center stage earlier this month when Ruby patched critical runtime flaws including a Rails remote code execution bug on November 18. Maintainers noted that even on Ruby versions immune to code execution, compiling a crafted regex pattern could crash an upload worker or exhaust server memory.
Telemetry Audit and Registry Security Hardening
Maintainers committed the validation patch to the RubyGems.org public repository on November 4, 2026 (UTC), three weeks ahead of the November 26 advisory. A review of production telemetry and 29,100 gems published between October 5 and November 4 found no direct evidence of exploitation. However, the team noted that limited log retention windows and unrecorded upload payloads meant earlier attempts could not be completely ruled out.
On the hosted RubyGems.org platform, schema validation now rejects any regexp-tagged gemspec field with an HTTP 422 error. The service also parses gem metadata through a restricted YAML loader that blocks YAML aliases and permits only the specific classes required by a valid gemspec. As an added defense, patterns inside OIDC access policies are now capped at 255 characters prior to compilation.
Regular Ruby developers and gem consumers do not need to take any action on the hosted registry. Organizations running self-hosted RubyGems.org instances should update to a commit containing the November 4 fix, while application teams should upgrade to Ruby 4.0.10, 3.4.13, or 3.3.14.
The disclosure arrives amid heightened scrutiny of software supply chain and infrastructure defects. Recent advisories include CISA and Juniper warning of an exploited Session Smart Conductor root command flaw and Broadcom patching a critical VMware vCenter zero-day exploited by hackers.