---
title: "RubyGems.org Regex Metadata Flaw Enables Registry RCE"
slug: "rubygems-regex-metadata-rce-flaw"
description: "Defensive teardown of GHSA-7h7w-m82c-x2xg: gemspec regex parsing flaw, CVSS 9.0, affected versions, patch commands, and detection rules for self-hosted"
author: "Hamdi Soudani"
category: "dev-tooling-benchmarks"
archetype: "advisory-teardown"
published_at: "2026-11-30T12:05:03.886+00:00"
updated_at: "2026-11-30T12:05:03.951011+00:00"
canonical_url: "https://pyvren.com/blog/rubygems-regex-metadata-rce-flaw"
reading_time_minutes: 3
word_count: 608
quality_score: 90
tags: ["rubygems","cve","devsecops","registry","rce"]
keywords: ["rubygems.org rce vulnerability","ghsa-7h7w-m82c-x2xg patch","self-hosted rubygems upgrade","gemspec metadata regex flaw","ruby regex engine cve-2026-110264"]
sources: ["https://github.com/rubygems/rubygems.org/security/advisories/GHSA-7h7w-m82c-x2xg","https://cybersecuritynews.com/critical-rubygems-vulnerability/amp/","https://saveality.net/en/vulnerabilities-exploits/ruby-fixes-regex-engine-bugs-behind-critical-gitlab-code-execution-fla-586426en/"]
---

# RubyGems.org Regex Metadata Flaw Enables Registry RCE

> **TL;DR:** GHSA-7h7w-m82c-x2xg lets any authenticated gem publisher run code on RubyGems.org registry servers via a gemspec metadata regex parsing flaw; self-hosted deployments must update to the fixed code revision.

## Key Facts

- **Advisory ID:** GHSA-7h7w-m82c-x2xg ([source](https://github.com/rubygems/rubygems.org/security/advisories/GHSA-7h7w-m82c-x2xg))
- **CVSS 4.0 Score:** 9.0 / 10 ([source](https://cybersecuritynews.com/critical-rubygems-vulnerability/amp/))
- **CVE Identifier:** None assigned ([source](https://cybersecuritynews.com/critical-rubygems-vulnerability/amp/))
- **Affected Component:** RubyGems.org gemspec metadata validator and YAML parser ([source](https://cybersecuritynews.com/critical-rubygems-vulnerability/amp/))
- **Ruby Versions with Regex Fixes:** 4.0.9, 3.4.12, 3.3.13 ([source](https://saveality.net/en/vulnerabilities-exploits/ruby-fixes-regex-engine-bugs-behind-critical-gitlab-code-execution-fla-586426en/))
- **Exploitation Evidence:** None found in 29,100 gems reviewed from Oct 5 to Nov 4, 2026 ([source](https://cybersecuritynews.com/critical-rubygems-vulnerability/amp/))

RubyGems.org disclosed a critical package upload flaw that could let any authenticated gem publisher execute code on registry servers. The vulnerability, tracked as GHSA-7h7w-m82c-x2xg with a CVSS 4.0 score of 9.0, stems from a mismatch between how the gemspec metadata validator and the YAML parser interpret the same field. No CVE identifier has been assigned. Maintainers found no direct evidence of exploitation on the public registry after reviewing 29,100 gems published from October 5 through November 4, 2026, though limited log retention means earlier attempts cannot be fully ruled out.

## Incident Timeline & Blast-Radius Table

| Item | Detail |
| --- | --- |
| Advisory ID | GHSA-7h7w-m82c-x2xg |
| CVSS 4.0 Score | 9.0 / 10 |
| CVE ID | None assigned |
| Initial access vector | Authenticated RubyGems.org account with publish API key |
| Affected versions | Self-hosted RubyGems.org deployments before the fixed code revision |
| Confirmed fix | Server-side patch rejecting regexes in text gemspec fields |
| Exploitation evidence | None found in reviewed production gems |
| Weakness class | CWE-502 deserialization of untrusted data |

The blast radius covers every self-hosted RubyGems.org registry instance that processes gem uploads. Hosted RubyGems.org users are protected by the server-side fix and require no client action. An attacker needs only a valid account and an API key permitted to publish packages; ownership of the target gem name is not required, and no action by another user is needed.

## Technical Root Cause & Attack Vector (Defensive Analysis)

Every gem carries a gemspec describing package metadata. The registry validates that metadata against field rules before accepting the upload. In the flawed path, the validator treated a metadata value as plain text while the YAML parser interpreted the same value as a regular expression. Because the registry processed metadata before checking whether the publisher owned the package name, the ownership gate could not prevent the parsing flaw from executing.

MITRE classifies this weakness as CWE-502, deserialization of untrusted data. In local testing with Ruby 4.0.9, the registry flaw combined with a separate memory corruption bug in Ruby’s regular expression compiler to allow code execution under the permissions of the gem upload worker process. Ruby builds not susceptible to code execution could still suffer upload worker crashes or out-of-memory conditions.

The related Ruby regex engine fixes shipped in versions 4.0.9, 3.4.12, and 3.3.13 address Onigmo bugs that could corrupt memory when compiling attacker-controlled patterns. Ruby 3.2 reached end of life on April 1, 2026 and will not receive patches. Setting Regexp.timeout does not stop these bugs, and limiting pattern length is unreliable because short patterns can also trigger them.

## Exact Patch, Upgrade & Verification Commands

Hosted RubyGems.org customers need no action. Self-hosted operators should update to the code revision containing the fix:

```bash
# Fetch the fixed rubygems.org revision
cd /opt/rubygems.org
git fetch origin
git checkout <fixed-revision-sha>

# Restart the upload worker service
systemctl restart rubygems-upload-worker

# Verify the running revision contains the fix
git rev-parse HEAD
```

Confirm that gemspec validation rejects regular expressions in text fields by submitting a test upload with a regex-like metadata value and verifying the registry rejects it before reaching the YAML parser.

## Detection Rules & Hardening Checklist

- Alert on upload worker crashes or out-of-memory events correlated with gem publication attempts.
- Review upload logs for gemspec fields containing regex delimiters or interpolation syntax.
- Ensure self-hosted RubyGems.org runs a code revision after the GHSA-7h7w-m82c-x2xg fix.
- Restrict publish API keys to least-privilege scopes and rotate compromised credentials.
- Monitor Ruby version on registry hosts; upgrade to 4.0.9, 3.4.12, or 3.3.13 where applicable.

![Critical RubyGems Flaw Could Have Let Any Gem Publisher Run Code on the Registry](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4kOAlrNdJPeiYZ8iWNwxba58TktUoF3Ei1ERYUi2vmGcBHdmyaB2FsRHJ0hTkr6DB4ZbMrqK02q-SVbKjpLfunNog-q9O-AXRBuhbOIa4u3p4BXA_9pQt4qZYA9hgc3nxHip1HUIKXaWq7yF7p-6sQ6jYxjYs67wS_CqiGYt4cTP8lr-ZvzFfV5WaMTk/s1700-nu-rw-lo-l85-e365/rubygems.jpg)

When NOT to use this guidance: hosted RubyGems.org consumers should not attempt client-side patches, because the flaw is server-side and already remediated by the registry operators. Self-hosted teams must treat the fix as a code-revision update, not a gem dependency upgrade.

Primary sources: [GitHub Security Advisory GHSA-7h7w-m82c-x2xg](https://github.com/rubygems/rubygems.org/security/advisories/GHSA-7h7w-m82c-x2xg), [Critical RubyGems Vulnerability Could Let Attackers Execute Code on Package Registry Servers](https://cybersecuritynews.com/critical-rubygems-vulnerability/amp/), [Ruby fixes regex-engine bugs behind critical GitLab code-execution flaws](https://saveality.net/en/vulnerabilities-exploits/ruby-fixes-regex-engine-bugs-behind-critical-gitlab-code-execution-fla-586426en/).

## Frequently Asked Questions

### Do hosted RubyGems.org users need to take action?

No. Developers using the hosted RubyGems.org service do not need to take action because maintainers applied the server-side fix.

### What must self-hosted RubyGems operators do?

Update to a code revision containing the fix rather than looking for a patched gem release, since the vulnerability lives in the registry upload path.

## Primary Sources

- https://github.com/rubygems/rubygems.org/security/advisories/GHSA-7h7w-m82c-x2xg
- https://cybersecuritynews.com/critical-rubygems-vulnerability/amp/
- https://saveality.net/en/vulnerabilities-exploits/ruby-fixes-regex-engine-bugs-behind-critical-gitlab-code-execution-fla-586426en/
