CVE-2026-57438: Nokogiri use-after-free in XInclude processing

CVE-2026-57438 · Severity: info · CVSS 2.2 · Published 2026-06-25

Nokogiri is a widely used Ruby library for processing XML and HTML documents. A technical flaw in how it handles specific document inclusions could allow a program to crash or behave unpredictably by accessing memory that has already been cleared. This issue primarily affects applications using specific, non-standard processing sequences and is resolved by updating the library.

Technologies: nokogiri (RubyGems). Vendors: RubyGems.

Quick answers

Is CVE-2026-57438 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-57438 being exploited in the wild.
How severe is CVE-2026-57438?
Informational severity, with a CVSS score of 2.2, 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-57438?
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-57438 attacked?
It is attacked with local access, in a software library.
Am I affected by CVE-2026-57438?
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 (CWE-416) vulnerability exists in the CRuby implementation of Nokogiri's XInclude processing. When `Nokogiri::XML::Node#do_xinclude` is called, it replaces `<xi:include>` nodes in place and frees the original nodes and their descendants. If the application has already referenced these nodes in Ruby, the Ruby objects remain linked to the now-freed memory, leading to invalid memory reads or writes. This requires a specific execution flow where a document is parsed without XInclude, traversed to expose nodes to Ruby, and then subsequently processed for XInclude. The issue is fixed in version 1.19.4 by performing substitutions on defensive copies.

Affected products

  • sparklemotion Nokogiri < 1.19.4

Identifiers

  • CVE-2026-57438
  • GHSA-wfpw-mmfh-qq69

Timeline

  • 2026-06-18: advisory: GitHub advisory published by maintainers
  • 2026-06-25: disclosed: CVE published to NVD
  • 2026-06-25: patched: Fixed in version 1.19.4

References

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