What’s Vulnerable › Vulnerabilities
CVE-2021-41098: Improper Restriction of XML External Entity Reference (XXE) in Nokogiri on JRuby
- Severity: high (CVSS 7.5 v3.1)
- Exploited in the wild: not listed in CISA KEV
- EPSS: 1.5% probability of exploitation in the next 30 days
- Public exploit or detection template: none known
- Published: 2021-09-27 · updated 2026-06-17
- Weakness: CWE-611
Description
Nokogiri is a Rubygem providing HTML, XML, SAX, and Reader parsers with XPath and CSS selector support. In Nokogiri v1.12.4 and earlier, on JRuby only, the SAX parser resolves external entities by default. Users of Nokogiri on JRuby who parse untrusted documents using any of these classes are affected: Nokogiri::XML::SAX::Parse, Nokogiri::HTML4::SAX::Parser or its alias Nokogiri::HTML::SAX::Parser, Nokogiri::XML::SAX::PushParser, and Nokogiri::HTML4::SAX::PushParser or its alias Nokogiri::HTML::SAX::PushParser. JRuby users should upgrade to Nokogiri v1.12.5 or later to receive a patch for this issue. There are no workarounds available for v1.12.4 or earlier. CRuby users are not affected.
Affected products
- sparklemotion nokogiri: before 1.12.5 — fixed in 1.12.5
- Rubygems Nokogiri: before 1.12.5; 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5 (+132) — fixed in 1.12.5
How to fix
Upgrade to a fixed version: sparklemotion nokogiri 1.12.5; Rubygems Nokogiri 1.12.5. Check the vendor advisory for mitigations.
References
- https://github.com/sparklemotion/nokogiri/commit/5bf729ff3cc84709ee3c3248c981584088bf9f6d
- https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-2rr5-8q37-2w7h
- https://github.com/sparklemotion/nokogiri/commit/5bf729ff3cc84709ee3c3248c981584088bf9f6d
- https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-2rr5-8q37-2w7h
Get alerted when CVE-2021-41098 or the next vulnerability affects your stack