RubyGems.org, the central registry for Ruby gems, has fixed a critical flaw that allowed any account with a push-capable API key to feed an attacker-controlled regular expression into gem metadata during upload.
In local testing, maintainers chained the issue with a memory corruption bug in Ruby's regexp compiler and achieved remote code execution. Gem users require no action as the hosted service is now secured. A review of production telemetry covering 29,100 gems published between October 5 and November 4 found no direct evidence of exploitation, though gaps in logging and payload recording leave earlier attempts unruled out.
The vulnerability, tracked as GHSA-7h7w-m82c-x2xg and scoring 9.0 on CVSS, resided in how the registry processed YAML metadata from gems. The validator overlooked the !ruby/regexp YAML tag, permitting fields to pass schema checks as plain text. Ruby's YAML library Psych then converted the field into a real regular expression, compiling any pattern supplied by the attacker before ownership verification of the gem name.
The test environment used Ruby 4.0.9, affected by seven flaws in the regexp engine and string case conversion patched on November 18. Even without code execution, compiling malicious patterns could crash upload workers or exhaust memory. Schema validation now rejects regexp-tagged gemspec fields with an HTTP 422 error, and metadata is processed with a restricted loader that disallows YAML aliases.
Additional safeguards include capping patterns in OIDC access policies at 255 characters. The fix was committed to the public repository on November 4. Self-hosted operators must update to a patched commit, while Ruby applications should migrate to Ruby 4.0.10, 3.4.13, or 3.3.14.


