Nokogiri::XML::Schema trusts input by default, exposing risk of XXE vulnerability
Published 30 Dec 2020 · Updated 8 Jul 2026
Is your project on an affected nokogiri?
Look after several Rails or Ruby apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Affected package
- Affected
- <1.11.0
- Fixed in
- 1.11.0
bundle update --conservative nokogiri # Gemfile: '>= 1.11.0'Details
Severity
Nokogiri maintainers have evaluated this as __Low Severity__ (CVSS3 2.6).
Description
In Nokogiri versions <= 1.11.0.rc3, XML Schemas parsed by Nokogiri::XML::Schema are trusted by default, allowing external resources to be accessed over the network, potentially enabling XXE or SSRF attacks.
This behavior is counter to the security policy followed by Nokogiri maintainers, which is to treat all input as untrusted by default whenever possible.
Please note that this security fix was pushed into a new minor version, 1.11.x, rather than a patch release to the 1.10.x branch, because it is a breaking change for some schemas and the risk was assessed to be "Low Severity".
Affected Versions
Nokogiri <= 1.10.10 as well as prereleases 1.11.0.rc1, 1.11.0.rc2, and 1.11.0.rc3
Mitigation
There are no known workarounds for affected versions. Upgrade to Nokogiri 1.11.0.rc4 or later.
If, after upgrading to 1.11.0.rc4 or later, you wish to re-enable network access for resolution of external resources (i.e., return to the previous behavior):
1. Ensure the input is trusted. Do not enable this option for untrusted input.
2. When invoking the Nokogiri::XML::Schema constructor, pass as the second parameter an instance of Nokogiri::XML::ParseOptions with the NONET flag turned off.
So if your previous code was:
# in v1.11.0.rc3 and earlier, this call allows resources to be accessed over the network # but in v1.11.0.rc4 and later, this call will disallow network access for external resources schema = Nokogiri::XML::Schema.new(schema) # in v1.11.0.rc4 and later, the following is equivalent to the code above # (the second parameter is optional, and this demonstrates its default value) schema = Nokogiri::XML::Schema.new(schema, Nokogiri::XML::ParseOptions::DEFAULT_SCHEMA)
Then you can add the second parameter to indicate that the input is trusted by changing it to:
# in v1.11.0.rc3 and earlier, this would raise an ArgumentError # but in v1.11.0.rc4 and later, this allows resources to be accessed over the network schema = Nokogiri::XML::Schema.new(trusted_schema, Nokogiri::XML::ParseOptions.new.nononet)
References
- This issue's public advisory
- Original Hackerone report (private)
- OWASP description of XXE attack_Processing)
- OWASP description of SSRF attack
Credit
This vulnerability was independently reported by @eric-therond and @gucki.
The Nokogiri maintainers would like to thank HackerOne for providing a secure, responsible mechanism for reporting, and for providing their fantastic service to us.
Is GHSA-vr8q-g5c7-m54m in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected nokogiri, and gives you the command that fixes it.
More advisories for nokogiri
- LowCVE-2026-126062JRuby: NONET is bypassed for external DTDs and entities when the systemId uses a short-form IPv4 host · 10 Nov 2026
- LowCVE-2026-126064Nokogiri: Use-After-Free in Nokogiri when replacing an attribute value · 10 Nov 2026
- LowCVE-2026-126063Nokogiri: Mutation XSS through `noscript` content in Nokogiri's HTML5 serializer · 10 Nov 2026
- LowCVE-2026-57435Nokogiri: Possible Use-After-Free when setting an attribute value via `Nokogiri::XML::Attr#value=` or `#content=` · 19 Jun 2026
- LowCVE-2026-57438Nokogiri: Possible Use-After-Free in XInclude Processing · 19 Jun 2026
- LowCVE-2026-57437Nokogiri: Possible Use-After-Free when directly using `NokogirI::XML::XPathContext` beyond document lifetime · 19 Jun 2026
References
- Linkgithub.com/sparklemotion/nokogiri/security/advisories/GHSA-vr8q-g5c7-m54m
- Advisorynvd.nist.gov/vuln/detail/CVE-2020-26247
- Linkgithub.com/sparklemotion/nokogiri/commit/9c87439d9afa14a365ff13e73adc809cb2c3d97b
- Linkhackerone.com/reports/747489
- Linkgithub.com/rubysec/ruby-advisory-db/blob/master/gems/nokogiri/CVE-2020-26247.yml
- Packagegithub.com/sparklemotion/nokogiri
- Linkgithub.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md#v1110--2021-01-03
- Linkgithub.com/sparklemotion/nokogiri/releases/tag/v1.11.0.rc4
- Linklists.debian.org/debian-lts-announce/2021/06/msg00007.html
- Linklists.debian.org/debian-lts-announce/2022/10/msg00018.html
- Linkrubygems.org/gems/nokogiri
- Linksecurity.gentoo.org/glsa/202208-29
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.