# Critical RubyGems.org Gemspec YAML Regexp Deserialization Flaw Could Have Allowed Code Execution on the Registry (GHSA-7h7w-m82c-x2xg)

> RubyGems.org fixed a critical flaw in gem metadata YAML parsing: the schema validator ignored the !ruby/regexp tag, so attacker-supplied patterns were compiled by Ruby's Psych library. Any account with a push-capable API key could trigger it without owning a gem, and chained with a Ruby regexp-compiler memory corruption bug on Ruby 4.0.9 it reached code execution in maintainers' local testing.

- **Author:** Threadlinqs Team
- **Published:** 2026-11-30T11:00:13Z
- **Last updated:** 2026-11-30T11:00:13Z
- **Canonical:** https://intel.threadlinqs.com/threat/TL-2026-7070
- **Card image:** https://intel.threadlinqs.com/og/threat/TL-2026-7070.png
- **ID:** TL-2026-7070
- **Severity:** CRITICAL (CVSS 9)
- **Category:** VULNERABILITY
- **Status:** PATCHED
- **Detections:** 9 (1 shown free below) · **IOCs:** 4
- **CVEs:** CVE-2024-35221

## Description

GHSA-7h7w-m82c-x2xg (published 2026-11-26 by the RubyGems.org maintainers, no CVE assigned) describes an authenticated remote code execution path in the RubyGems.org gem push pipeline. The gemspec metadata validator kept !ruby/regexp on its IGNORED_TAGS list, so a field carrying that YAML tag passed schema validation as plain text. Psych's to_ruby then deserialized the field into a real Regexp object, compiling an attacker-controlled pattern (CWE-502, Deserialization of Untrusted Data).

This validation ran before the registry checked whether the pushing account owned the gem name. Any account holding a push-capable API key could therefore reach the code path; no ownership of any existing gem was required. On its own, compiling a malicious pattern could crash an upload worker or exhaust its memory, even on non-vulnerable Ruby builds. On Ruby 4.0.9, the maintainers chained it with a memory corruption bug in the Ruby regexp compiler and reached code execution with upload worker privileges in local testing. The chain was not reproduced against the live service, and the advisory does not identify which memory corruption bug was used.

Remediation in the RubyGems.org codebase: !ruby/regexp was removed from IGNORED_TAGS so regexp-tagged gemspec fields are rejected with HTTP 422; to_ruby was replaced by a restricted safe_to_ruby loader that refuses YAML aliases, blocks Ruby classes in checksums.yaml and allows only specific Gem and core classes; and OIDC::AccessPolicy string_matches patterns are capped at 255 characters, with RegexpError converted to AccessError. The schema validation change entered the public repository on 2026-11-04 (UTC). The hosted registry is fixed and gem users need no action; self-hosted operators must update to a commit containing the fix.

Exploitation status: a review of 29,100 gems published between 2026-10-05 and 2026-11-04 found no direct evidence of exploitation, but log retention was limited and upload payloads were not recorded, so earlier attempts cannot be ruled out. The advisory does not say whether an attacker could have reached published gems or publishing credentials. Separately, on 2026-11-18 the Ruby project patched seven regexp and string case-conversion memory-safety flaws (fixed in Ruby 4.0.10, 3.4.13 and 3.3.14), five of which have RCE PoCs; Ruby operators should update regardless of registry fix status. The advisory scores the flaw CVSS v4.0 9.0.

## MITRE ATT&CK

- T1190 Exploit Public-Facing Application
- T1195.002 Compromise Software Supply Chain
- T1078 Valid Accounts
- T1059 Command and Scripting Interpreter
- T1499.004 Endpoint Denial of Service: Application or System Exploitation

## Free detection (Splunk SPL, Microsoft KQL, Sigma)

**RubyGems.org Gem Push Rejected With HTTP 422 - Regexp-Tagged Gemspec Probe (GHSA-7h7w-m82c-x2xg)** (`TL-2026-7070-SPL-001`)

Exploitation-phase detection for self-hosted RubyGems.org instances. The fixed registry rejects gem push uploads whose gemspec carries a !ruby/regexp YAML tag with HTTP 422 (GHSA-7h7w-m82c-x2xg, CWE-502). Repeated 422 responses on POST /api/v1/gems from one client in an hour is the best web-tier signal of probing for the Psych regexp deserialization path, because the flaw is reachable with any push-capable API key before the ownership check. Unpatched instances will not return 422, so this also serves as a hunt for pre-patch probing once the fix is deployed. Exploitation is rated THEORETICAL and no in-the-wild abuse is confirmed; payloads are not in access logs, so treat hits as leads to be confirmed against upload logs.

- **Languages:** Splunk SPL, Microsoft KQL, Sigma
- **ATT&CK:** T1190, T1195.002, T1078
- **Data sources:** web:access_combined (nginx/Apache in front of self-hosted rubygems.org), azure_application_gateway_access_log
- **Severity:** medium
- **Confidence:** medium

### Splunk SPL

```spl
index=web sourcetype=access_combined method=POST uri_path="/api/v1/gems" status=422 earliest=-24h | bin _time span=1h | stats count AS rejected_pushes dc(uri_path) AS distinct_paths values(useragent) AS user_agents min(_time) AS first_seen max(_time) AS last_seen BY clientip, _time | where rejected_pushes>=3 | eval threat_id="TL-2026-7070", advisory="GHSA-7h7w-m82c-x2xg", first_seen=strftime(first_seen,"%F %T"), last_seen=strftime(last_seen,"%F %T") | table threat_id advisory _time clientip rejected_pushes distinct_paths user_agents first_seen last_seen | sort - rejected_pushes
```

### Microsoft KQL

```kql
AzureDiagnostics
| where TimeGenerated > ago(24h)
| where Category == "ApplicationGatewayAccessLog"
| where httpMethod_s == "POST" and requestUri_s startswith "/api/v1/gems" and httpStatus_d == 422
| summarize RejectedPushes = count(), UserAgents = make_set(userAgent_s, 5), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated) by clientIP_s, bin(TimeGenerated, 1h)
| where RejectedPushes >= 3
| project TimeGenerated, clientIP_s, RejectedPushes, UserAgents, FirstSeen, LastSeen
```

### Sigma

```yaml
title: RubyGems.org Gem Push Rejected With HTTP 422 (Regexp-Tagged Gemspec Probe)
id: 3b1f6c52-8a4e-4d7b-9c21-5e0a7d4f1b83
status: experimental
description: Detects POST requests to the RubyGems.org gem push endpoint answered with HTTP 422, the response the fixed registry returns for gemspec fields carrying the !ruby/regexp YAML tag (GHSA-7h7w-m82c-x2xg). Aggregate by client in the SIEM (3 or more per hour) to reduce noise from ordinary invalid pushes.
references:
  - https://github.com/rubygems/rubygems.org/security/advisories/GHSA-7h7w-m82c-x2xg
author: Threadlinqs Team
date: 2026-11-30
tags:
  - attack.initial-access
  - attack.t1190
  - attack.t1195.002
  - attack.t1078
logsource:
  category: webserver
detection:
  selection:
    cs-method: 'POST'
    cs-uri-stem|startswith: '/api/v1/gems'
    sc-status: 422
  condition: selection
falsepositives:
  - Maintainers pushing gems with malformed or invalid gemspec metadata
  - CI pipelines with a misconfigured gem build
level: medium
```

**Known false positives:**

- Legitimate maintainers pushing gems with malformed gemspec metadata (any validation failure returns 422)
- CI/CD pipelines retrying a failing gem push in a loop

**Tuning notes:** Adjust the index/sourcetype to your reverse-proxy log source and the 3-per-hour threshold to your push volume. Exclude known CI egress IPs. Pivot on the API key or account ID in the Rails push log, since access logs do not carry the key. Only the fixed registry returns 422 for this tag, so deploy the fix commit first.

### 8 more detection rules (Splunk SPL, Microsoft KQL, Sigma), unlock with TL Creds

- [indicator] Application Log - !ruby/regexp Tag or Restricted YAML Loader Rejection (locked: unlock with TL Creds)
- [indicator] Worker Crash, Segfault or OOM Kill - Regexp Memory Corruption or Resource Exhaustion (locked: unlock with TL Creds)
- [indicator] Upload Worker Beaconing - Regular Outbound Connections With Low Jitter (locked: unlock with TL Creds)
- [indicator] OIDC AccessPolicy Regexp Error or Oversized Pattern (Trusted Publishing) (locked: unlock with TL Creds)
- [indicator] Upload Worker Spawning Download, Netcat or Persistence Tooling (locked: unlock with TL Creds)
- Reverse Shell Command Lines From Ruby Worker Host (dev/tcp, TCPSocket, mkfifo, nc -e) (locked: unlock with TL Creds)
- [indicator] Upload Worker Spawning a Shell Interpreter (Post-Exploitation of Regexp Chain) (locked: unlock with TL Creds)
- [indicator] Upload Worker Outbound Connection to Public IP (Post-Exploitation Callback) (locked: unlock with TL Creds)

Sign up free to unlock the detection rules: https://threadlinqs.com/?modal=signup

## Sources

- [Critical RubyGems Flaw Could Have Let Any Gem Publisher Run Code on the Registry](https://thehackernews.com/2026/11/critical-rubygems-flaw-could-have-let.html)
- [GHSA-7h7w-m82c-x2xg: Authenticated RCE in RubyGems.org gem pushes via !ruby/regexp gemspec tags](https://github.com/rubygems/rubygems.org/security/advisories/GHSA-7h7w-m82c-x2xg)
- [Multiple vulnerabilities in Regexp and String (Ruby security announcement)](https://www.ruby-lang.org/en/news/2026/11/18/multiple-vulnerabilities-in-regexp-and-string/)
- [Ruby Releases Fixes for 7 Regex and Case Conversion Flaws](https://thehackernews.com/2026/11/ruby-releases-fixes-for-7-regex-and.html)
- [RubyGems.org statistics](https://rubygems.org/stats)
- [CVE-2024-35221: RubyGems.org YAML alias denial of service in gem metadata (related prior issue)](https://nvd.nist.gov/vuln/detail/CVE-2024-35221)
- [GHSA-mqwr-4qf2-2hcv: Unsafe YAML deserialization in RubyGems via gem spec class allow-list bypass (related prior issue)](https://cve.circl.lu/vuln/GHSA-mqwr-4qf2-2hcv)

## Full data

The other 8 detection rules (Splunk SPL / Microsoft KQL / Sigma) unlock with TL Creds; a free account includes daily creds: https://threadlinqs.com/?modal=signup
Indicator values unlock with TL Creds, at a lower price on Red and Purple; AI agents can query rules and IOCs through the Threadlinqs MCP server (Purple and Gold in full, 2 calls a day on a free account): https://intel.threadlinqs.com/mcp

Canonical: https://intel.threadlinqs.com/threat/TL-2026-7070
