Skip to main content

RubyGems.org Regex Metadata Flaw Enables Registry RCE

Defensive teardown of GHSA-7h7w-m82c-x2xg: gemspec regex parsing flaw, CVSS 9.0, affected versions, patch commands, and detection rules for self-hosted

BREACHES & CVES Security Advisory
Critical RubyGems Flaw Could Have Let Any Gem Publisher Run Code on the Registry
Critical RubyGems Flaw Could Have Let Any Gem Publisher Run Code on the Registry Source: thehackernews.com
Field Note · The Short Version 3 min read

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 Numbers & Verified Specs

6 metrics
Metric / Spec Verified Finding Source
Advisory ID GHSA-7h7w-m82c-x2xg github.com
CVSS 4.0 Score 9.0 / 10 cybersecuritynews.com
CVE Identifier None assigned cybersecuritynews.com
Affected Component RubyGems.org gemspec metadata validator and YAML parser cybersecuritynews.com
Ruby Versions with Regex Fixes 4.0.9, 3.4.12, 3.3.13 saveality.net
Exploitation Evidence None found in 29,100 gems reviewed from Oct 5 to Nov 4, 2026 cybersecuritynews.com
Jump to section (4) +

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

ItemDetail
Advisory IDGHSA-7h7w-m82c-x2xg
CVSS 4.0 Score9.0 / 10
CVE IDNone assigned
Initial access vectorAuthenticated RubyGems.org account with publish API key
Affected versionsSelf-hosted RubyGems.org deployments before the fixed code revision
Confirmed fixServer-side patch rejecting regexes in text gemspec fields
Exploitation evidenceNone found in reviewed production gems
Weakness classCWE-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:

Bash10 lines
# 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
Critical RubyGems Flaw Could Have Let Any Gem Publisher Run Code on the Registry

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, Critical RubyGems Vulnerability Could Let Attackers Execute Code on Package Registry Servers, Ruby fixes regex-engine bugs behind critical GitLab code-execution flaws.

Reader Q&A

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.

Bibliography & Verification

Primary Sources & References

3 cited sources
  1. [01] github.com security / advisories / GHSA-7h7w-m82c-x2xg
  2. [02] cybersecuritynews.com critical-rubygems-vulnerability / amp
  3. [03] saveality.net en / vulnerabilities-exploits / ruby-fixes-regex-engine-bugs-behind-cri…

Human × Agent Co-Work

Hamdi Soudani · in collaboration with Pyvren

Systems engineer & technical writer exploring AI infrastructure, security, and edge craft in daily collaboration with Pyvren.

Hamdi Soudani × Pyvren

Honest engineering stories — co-crafted with primary benchmarks & real code

Every dispatch blends hands-on engineering judgment with verified primary sources, reproducible configs, and clear tradeoffs.