RubyGems.org — the central package registry for the Ruby ecosystem, serving around 199,000 gems — has fixed a critical vulnerability (GHSA-7h7w-m82c-x2xg, CVSS 9.0) that allowed any authenticated user with a publishing API key to inject an arbitrary regular expression via a gem’s YAML metadata. According to the official advisory, in local testing on Ruby 4.0.9 the registry maintainers were able to chain this vulnerability with a memory-corruption bug in Ruby’s regular expression engine and achieve remote code execution. The hosted service has already been patched; gem consumers do not need to take any action, but operators of self-hosted RubyGems.org instances and Ruby developers need to update.
Vulnerability mechanism
The root cause lies in how YAML metadata, which every gem carries in its specification (gemspec), was handled. The registry’s schema validator for this metadata ignored the YAML tag !ruby/regexp. A field marked with this tag would pass validation as normal text. However, at the next stage the Psych library (Ruby’s standard YAML parser) deserialized this field into a real regular expression object, compiling whatever pattern the sender had provided.
A critically important detail: this whole process — validation and deserialization — took place before checking whether the uploaded gem name belonged to the sender’s account. This meant the attacker did not need to own any gem at all — it was enough to have any account with an API key that allowed uploads (POST /api/v1/gems).
On Ruby 4.0.9, which contained vulnerabilities in the regular expression engine and string case-conversion mechanism, the attacker-controlled pattern made it possible to achieve arbitrary code execution with the privileges of the gem upload worker process. Even on Ruby builds that were not susceptible to code execution, compiling a malicious pattern could cause the worker to crash or exhaust memory — resulting in a denial of service.
Exploit status and investigation limitations
According to the advisory, an examination of production telemetry and 29,100 gems published between 5 October and 4 November 2026 did not reveal direct evidence of exploitation. However, the maintainers explicitly point out the limitations of this conclusion: logs were not retained long enough, and the contents of uploaded packages were not recorded, so earlier exploitation attempts cannot be ruled out.
It is important to distinguish that the remote code execution demonstration was carried out in a local environment, not against the live service. The advisory does not disclose whether an attacker who achieved code execution in the context of the upload worker process could have reached published gems or publishing credentials.
Mitigations implemented
The registry introduced several layers of protection:
- Tag blocking at validation level: the
!ruby/regexptag has been removed from the list of ignored tags in the validator. Gemspec fields with this tag are now rejected with an HTTP 422 error before the deserialization stage. - Restricted YAML loader: calls to unrestricted deserialization have been replaced with a safer variant (
safe_to_ruby) that usesPsych::ClassLoader::Restrictedand forbids YAML aliases. Only the classes necessary for a valid gemspec are allowed. - OIDC pattern restrictions: string patterns in OIDC access policies are limited to 255 characters before compilation — an additional safeguard against resource exhaustion by the regular expression compiler.
The validation fix landed in the registry’s public code repository on 4 November (UTC), three weeks before public disclosure.
Related vulnerabilities in Ruby
The exploit chain relied on a separate set of vulnerabilities in Ruby itself. According to the Ruby project announcement of 18 November, seven vulnerabilities in the regular expression engine and string case-conversion mechanism were disclosed, and proof-of-concept exploits exist for some of them that can trigger remote code execution.
Affected Ruby versions:
- Ruby 3.3.13 and earlier
- Ruby 3.4.0 — 3.4.12
- Ruby 4.0.0 — 4.0.9
Fixes are available in Ruby 4.0.10, 3.4.13 and 3.3.14. Ruby 3.2 and earlier have reached end of life and will not receive updates.
Impact assessment
The vulnerability affected an infrastructure component of the Ruby ecosystem — the central registry through which distribution of all public gems passes. Although the barrier to launching an attack was relatively low (any account with a publishing API key), actual damage depended on the Ruby version running on the server and the privileges of the upload worker process. The lack of information on the possibility of lateral movement from the worker process to the gem storage or credentials leaves open the question of the potential scale of supply chain compromise.
Recommendations
- Users of gems via rubygems.org: no action is required — the hosted service has been patched.
- Operators of self-hosted RubyGems.org instances: you need to update your deployment to a commit that includes the fix.
- Ruby application developers: regardless of the registry vulnerability, update your Ruby runtime to versions 4.0.10, 3.4.13 or 3.3.14 to address the seven vulnerabilities in the regular expression engine and string conversion. This is a separate attack surface relevant to any application that compiles regular expressions from external data.
- Organizations using Ruby 3.2 and below: these versions will not receive fixes — plan a migration to a supported branch.
This incident illustrates the systemic risk of unsafe YAML deserialization in server-side ecosystem components. Operators of self-hosted registry instances should update immediately, and Ruby development teams should prioritize upgrading the runtime to fixed versions, especially if their applications process YAML or regular expressions from untrusted sources.












