CVE-2026-57436: Nokogiri: Possible Use-After-Free when setting `Document#root=` to an invalid node type
Nokogiri is an open source XML and HTML library for the Ruby programming language. Prior to 1.19.4, Nokogiri::XML::Document#root= validated only that the new root was a Nokogiri::XML::Node, allowing a DTD node to be set as the document root. The result is a heap use-after-free during garbage collection or finalization, leading to an invalid memory read or potentially a segfault. This vulnerability is fixed in 1.19.4.
Other sources
Nokogiri: Possible Use-After-Free when setting Document#root= to an invalid node type
— Microsoft
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 1.19.4-1 - Upgrade
Upgrade
Nokogirito a version that resolves this vulnerability.Fixed in 1.19.4
Event History
Frequently Asked Questions
What is the severity of CVE-2026-57436?
The severity of CVE-2026-57436 is rated as risk 27.
How do I fix CVE-2026-57436?
To fix CVE-2026-57436, upgrade Nokogiri to version 1.19.4 or later.
What kind of vulnerability is CVE-2026-57436?
CVE-2026-57436 is classified as a Use After Free vulnerability.
What software is affected by CVE-2026-57436?
Nokogiri versions prior to 1.19.4 are affected by CVE-2026-57436.
How does CVE-2026-57436 impact security?
CVE-2026-57436 allows for a heap use-after-free condition during garbage collection, which can lead to exploitation.