Critical RubyGems Vulnerability Allows Code Execution on Registry Servers
A critical vulnerability in RubyGems.org could allow authenticated attackers to execute code on registry servers by exploiting how gem metadata is processed.

RubyGems.org has disclosed a critical flaw in its package upload process that could permit authenticated attackers to execute arbitrary code on the registry servers. The vulnerability, identified as GHSA-7h7w-m82c-x2xg, stems from differing interpretations of gem metadata between the validator and the YAML parser.
Maintainers demonstrated remote code execution in a local test environment using Ruby 4.0.9. The vulnerability, classified under CWE-502 (deserialization of untrusted data), arises because the registry processed metadata before verifying package ownership. This allowed an attacker with a RubyGems.org account and publishing privileges to exploit the flaw before an ownership check could prevent it.
The GitHub security advisory, published on November 26, 2026, assigns a CVSS 4.0 score of 9.0 out of 10. While no direct exploitation on the public RubyGems.org service has been confirmed, the advisory notes that even unsuccessful attempts could lead to upload worker crashes or memory exhaustion.
In the context of the vulnerability, a gem's specification (gemspec) contains metadata that the registry validates. The issue occurred when a specific part of this metadata was treated as plain text by the validator but interpreted as a regular expression by the YAML parser. This discrepancy created an avenue for exploitation.
In local testing, the combination of this registry flaw and a separate memory corruption bug in Ruby's regular expression compiler enabled code execution with the privileges of the gem upload process. However, an extensive review of production activity, including over 29,100 gems published between October 5 and November 4, 2026, found no direct evidence of exploitation on the live service.
The fix implemented by RubyGems.org involves rejecting regular expressions in gemspec fields that are expected to contain plain text and limiting the types of Ruby objects that the parser can instantiate. Developers using the hosted RubyGems.org service do not need to take any action, as the fix has been deployed.
For organizations running self-hosted RubyGems.org deployments, it is crucial to update to a code revision that includes the fix. This advisory differs from previous security incidents involving malicious gems that targeted developers directly through installed packages; this vulnerability resides on the server-side, affecting the upload process before packages are made available to users.
This incident highlights the ongoing risks associated with package registry security and the importance of robust validation and parsing mechanisms for uploaded code and metadata. The vulnerability underscores the need for continuous security auditing of critical infrastructure components used by developers worldwide.
The vulnerability, identified as GHSA-7h7w-m82c-x2xg, was rated with a CVSS score of 9.0 but did not receive a CVE assignment. While the registry maintainers found no direct evidence of exploitation in production telemetry, they noted that logs were insufficient to rule out earlier attempts. The fix involved changes to how the registry validates gem metadata, specifically by rejecting regexp-tagged gemspec fields and employing a restricted YAML loader.