CVE-2026-57436: Nokogiri use-after-free in Document root assignment

CVE-2026-57436 · Severity: medium · CVSS 4 · Published 2026-06-25

Nokogiri is a widely used Ruby library for processing XML and HTML data. A technical flaw in how the library handles document structures could allow a programming error to crash the application or cause unpredictable behavior. This issue primarily affects the stability of the service and is resolved by updating to the latest version of the library.

Technologies: nokogiri (RubyGems). Vendors: RubyGems.

Quick answers

Is CVE-2026-57436 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-57436 being exploited in the wild.
How severe is CVE-2026-57436?
Medium severity, with a CVSS score of 4, published 25 June 2026.
Which products and versions are affected?
nokogiri (RubyGems) ECOSYSTEM:introduced=0,fixed=1.19.4.
Is there a fix for CVE-2026-57436?
Yes. nokogiri (RubyGems): upgrade to 1.19.4 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2026-57436 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2026-57436?
Check whether you run nokogiri (RubyGems) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • nokogiri (RubyGems): upgrade to 1.19.4 or later
    bundle update nokogiri

Technical details

A use-after-free vulnerability exists in the CRuby implementation of Nokogiri (libxml2) within the `Nokogiri::XML::Document#root=` method. The component failed to properly restrict the type of node being assigned as the document root, allowing non-element nodes such as DTD nodes to be set. This leads to a heap use-after-free condition during garbage collection or finalization, potentially causing an invalid memory read or a segmentation fault. The vulnerability is triggered by specific application code patterns rather than direct untrusted input. It is fixed in version 1.19.4, which now enforces that only element nodes can be assigned as roots.

Affected products

  • sparklemotion Nokogiri < 1.19.4

Identifiers

  • CVE-2026-57436
  • GHSA-wjv4-x9w8-wm3h

Timeline

  • 2026-06-18: advisory: GitHub Security Advisory published
  • 2026-06-25: disclosed: CVE published to NVD

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.