The Hacker News
RubyGems fixes flaw that could let gem publishers run code
RubyGems[.]org fixed a critical flaw that allowed an attacker with a push-capable API key to inject an attacker-controlled regular expression into a gem’s metadata via YAML. The registry’s maintainers say the exploit chain combined a YAML tag handling gap with Ruby’s regex engine, leveraging Psych to compile the attacker’s pattern and potentially achieve remote code execution during gem uploads.
The vulnerability stemmed from how the registry parsed gemspec metadata, specifically the !ruby/regexp tag, which was treated as plain text by the validator but then evaluated as a regular expression by Psych.
In testing, researchers demonstrated that this could run arbitrary code in a remote environment, though the advisory notes there was no direct evidence of exploitation in production. The issue was tracked as GHSA-7h7w-m82c-x2xg and carries a CVSS score of 9.0, with no CVE assigned. RubyGems[.]org states that the attack could occur even if the attacker did not own the gem name, as the exploit happened before ownership checks on the hosted service.
Affected Ruby versions include those with seven known flaws in the regexp engine and string case conversion, patched in Ruby 4.0.10, 3.4.13 and 3.3.14. The registry has implemented schema validation changes (HTTP 422 for regexp-tagged fields) and a restricted YAML loader to mitigate the issue, with commits reflecting the fix visible in the repository from 4 November 2026 (UTC).