Ce mail provient de l'extérieur, restons vigilants

=====================================================================


                            CERT-Renater

                Note d'Information No. 2026/VULN1224

_____________________________________________________________________

DATE                : 30/11/2026

HARDWARE PLATFORM(S): /

OPERATING SYSTEM(S): Systems running Registry (RubyGems).

====================================================================
https://github.com/rubygems/rubygems.org/security/advisories/GHSA-7h7w-m82c-x2xg
_____________________________________________________________________


Authenticated remote code execution in RubyGems.org gem pushes via
!ruby/regexp gemspec tags

Critical
colby-swandale published GHSA-7h7w-m82c-x2xg

Package
Registry (RubyGems)

Affected versions
-1

Patched versions
None

Description

Summary

RubyGems.org's gem-push validator ignored the !ruby/regexp YAML tag
during schema validation, then Psych deserialised it into an
attacker-controlled regular expression. Any authenticated user with
a push-capable API key could submit crafted gem metadata to
POST /api/v1/gems and trigger regexp compilation in the upload
process before gem-name ownership checks ran. On Ruby 4.0.9,
chaining this with a memory corruption bug in Ruby's regexp
compiler allowed remote code execution in local testing.


Details

When a gem is pushed to POST /api/v1/gems, GemValidator:ackage
validates the gemspec YAML AST against a schema before converting
it to Ruby objects with gemspec_ast.to_ruby. Because
GemValidator::NodeInfo::IGNORED_TAGS listed !ruby/regexp,
GemValidator::NodeInfo.read_tag returned nil for nodes carrying
that tag. A gemspec string field such as
summary: !ruby/regexp /.../ passed schema validation as
an untagged scalar, and to_ruby then deserialised it into
a Regexp object, compiling the attacker-supplied pattern.

Validation and deserialisation run before Pusher checks gem
ownership, so any account with a push-capable API key could
reach this path without owning an existing gem.


Impact

An attacker only needs a RubyGems.org account and a
push-capable API key, not ownership of any gem. On Ruby 4.0.9,
crafted gemspec patterns achieved remote code execution with
the privileges of the gem-upload worker process in local
testing. Even on Ruby builds not vulnerable to code execution,
attacker-controlled regexp compilation can crash or exhaust
memory in a worker.

This was reproduced locally against Ruby 4.0.9 rather than
against the live service. A review of production telemetry
and 29,100 gems published between 5 October and
4 November 2026 found no direct evidence of exploitation,
though log retention and unlogged upload payloads do not
rule out earlier attempts.
Fix

    Removed !ruby/regexp from GemValidator::NodeInfo::IGNORED_TAGS,
so schema validation rejects regexp-tagged gemspec fields before
deserialisation and returns HTTP 422 with expected no tag,
but got "!ruby/regexp" path: /summary.

    Replaced unrestricted to_ruby calls in GemValidator:ackage
with safe_to_ruby, which uses Psych::ClassLoader::Restricted and
Psych::Visitors::NoAliasRuby to refuse YAML aliases, disallow
Ruby classes in checksums.yaml, and allow only the classes a
valid gemspec uses: Gem::Specification, Gem::Version,
Gem::Requirement, Gem:ependency, Gem::Version::Requirement,
Symbol, Time, and Date.

    Capped OIDC::AccessPolicy string_matches patterns at 255
characters before compilation as defence in depth against
regexp-compiler exhaustion, and converted RegexpError during
token exchange into an AccessError.

RubyGems.org is a hosted service, so gem users do not need
to take action. Operators running a self-hosted RubyGems.org
deployment should update to a commit containing the fix.


Severity
Critical
9.0/ 10

CVSS v4 base metrics
Exploitability Metrics
Attack Vector Network
Attack Complexity High
Attack Requirements Present
Privileges Required Low
User interaction None
Vulnerable System Impact Metrics
Confidentiality High
Integrity High
Availability High
Subsequent System Impact Metrics
Confidentiality High
Integrity High
Availability High
CVSS:4.0/AV:N/AC:H/AT/PR:L/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H

CVE ID
No known CVE

Weaknesses
Weakness CWE-502

Credits

    @colby-swandale colby-swandale Remediation developer
    @dkw-oss dkw-oss Remediation developer



=========================================================
+ CERT-RENATER        |    tel : 01-53-94-20-44         +
+ 23/25 Rue Daviel    |    fax : 01-53-94-20-41         +
+ 75013 Paris         |   email:cert@support.renater.fr +
=========================================================




