CVE-2026-57438: Nokogiri XInclude Use-After-Free Vulnerability (CVSS 6.6)
Nokogiri, a widely-used Ruby library for parsing XML and HTML, has a memory safety flaw in its XInclude feature. When the library processes XInclude directives (a standard XML feature that lets documents reference external content), it frees memory without properly notifying Ruby objects that may still reference it. If your application code has kept a reference to a fallback element or namespace from an included file, using that reference afterward can read from or write to memory that's no longer valid, potentially causing crashes or unexpected behavior.
Source data · NVD / CISA · public domain
- CVSS
- 3.1 · 6.6 MEDIUM · CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:H
- Weaknesses (CWE)
- CWE-416
- Affected products
- 1 configuration(s)
- Published / Modified
- 2026-06-25 / 2026-06-26
NVD description (verbatim)
Nokogiri is an open source XML and HTML library for the Ruby programming language. Prior to 1.19.4, XInclude substitution performed by Nokogiri::XML::Node#do_xinclude replaced each <xi:include> in place, freeing the include node along with its children (such as <xi:fallback> and its descendants) and any namespaces declared on them. If an application had already exposed one of those nodes or namespaces to Ruby, the corresponding Ruby object was left pointing at freed memory. Using the object could result in invalid reads or writes to memory. This vulnerability is fixed in 1.19.4.
1 reference(s) · View on NVD →
SEC.co analysis · AI-assisted, reviewed against source
Technical summary
CVE-2026-57438 is a use-after-free vulnerability (CWE-416) in Nokogiri's XInclude substitution handler. The Nokogiri::XML::Node#do_xinclude method replaces xi:include elements in place and deallocates the include node, its children (including xi:fallback descendants), and associated namespace declarations. If a Ruby application has already exposed references to these freed nodes or their namespace objects before XInclude processing completes, those Ruby objects become dangling pointers. Subsequent operations on such objects cause invalid memory access, potentially enabling out-of-bounds reads or writes. The vulnerability exists in versions prior to 1.19.4.
Business impact
Applications using Nokogiri to process XML documents with XInclude directives face availability and data integrity risks. A crafted or legitimate XML document that triggers XInclude substitution could cause application crashes if the affected code path is exercised. In scenarios where memory corruption leads to uncontrolled writes, there is a narrow but non-zero risk of information disclosure or application state corruption. Organizations that store or process sensitive XML data using vulnerable versions should treat this as a moderate-priority issue, particularly if user-supplied XML is processed with XInclude enabled.
Affected systems
Nokogiri versions prior to 1.19.4 are affected. This includes all 1.x versions up to and including 1.19.3. Ruby applications that use Nokogiri for XML or HTML parsing—especially those that rely on XInclude functionality—are in scope. The vulnerability requires application code to explicitly process XInclude directives (via do_xinclude) and retain references to included nodes or their namespaces, making it somewhat niche but not rare in document processing workflows.
Exploitability
The vulnerability requires local code execution context (the CVSS vector specifies AV:L, local access vector) and low privileges (PR:L). An attacker cannot exploit this remotely by simply sending malicious XML to an exposed service; rather, an authenticated or local user must trigger XInclude processing on a specially crafted XML document while the application maintains references to the affected nodes. The attack surface is limited to applications that both parse XInclude directives and expose intermediate node references to user-accessible code. This is not a trivial exploit path, but it is achievable in multi-tenant or shared hosting scenarios.
Remediation
Upgrade Nokogiri to version 1.19.4 or later. This patch version includes memory management fixes that ensure freed nodes are properly invalidated in the Ruby layer, preventing use-after-free conditions. Organizations should coordinate patching with their Ruby application deployments, as Nokogiri is a native extension that may require compilation during install.
Patch guidance
Apply Nokogiri version 1.19.4 or newer. Verify the patch version by checking your Gemfile.lock (for Bundler-managed projects) or running `gem list nokogiri` in your Ruby environment. For containerized deployments, rebuild images with the patched gem version. If Nokogiri is vendored within your application, regenerate the lock file and commit the upgrade. Test XML processing workflows that rely on XInclude to confirm no regressions are introduced.
Detection guidance
Review application code for calls to do_xinclude on XML documents. Check whether your Ruby code exposes or stores references to nodes, attributes, or namespace objects that might originate from XInclude-processed XML. If your application processes XML from untrusted sources and retains node references, prioritize patching. For runtime detection, monitor application logs for segmentation faults or memory corruption errors that coincide with XML processing tasks. SIEM rules should flag unexpected crashes in Ruby processes handling XML data.
Why prioritize this
Although the CVSS score is moderate (6.6), the confluence of memory safety issues with local privileges and high availability impact (the A:H component) warrants prompt attention. Organizations should prioritize patching within 30 days, especially if XInclude is actively used. The lack of KEV designation indicates limited public exploitation, but memory corruption flaws tend to receive researcher focus over time.
Risk score, explained
The CVSS 3.1 score of 6.6 (MEDIUM) reflects the local attack vector, low privilege requirement, and lack of user interaction, balanced against the high availability impact and confidentiality/integrity concerns. The low attack complexity and no-scope constraint limit the severity from HIGH to MEDIUM. However, the use-after-free nature of the flaw elevates practical risk in memory-critical environments; defenders should not view MEDIUM severity as low priority.
Frequently asked questions
Can this vulnerability be exploited remotely over the network?
No. The CVSS vector specifies AV:L (local access vector), meaning an attacker must have local code execution or authenticated access to the system running Nokogiri. Remote XML parsing services that don't expose node references to untrusted callers face reduced risk, but network-accessible applications should still patch promptly.
Do we need to update if we don't use XInclude features?
If your application never calls do_xinclude on XML documents, the vulnerable code path is not triggered. However, if you use a framework or dependency that enables XInclude automatically, or if you process XML where XInclude might be embedded, upgrading is prudent to eliminate the attack surface entirely.
What versions of Ruby are affected?
The vulnerability affects Nokogiri itself, not Ruby versions. However, Nokogiri 1.19.4+ requires Ruby 2.7 or later (verify against the vendor's release notes). Ensure your Ruby environment meets the minimum version before upgrading.
Is there a workaround if we can't patch immediately?
The most reliable workaround is to avoid calling do_xinclude on untrusted XML, or to avoid retaining references to nodes that may be processed by XInclude. However, this is not a robust long-term solution. Patching is strongly recommended; upgrade Nokogiri within your scheduled maintenance window.
This analysis is provided for informational purposes and should not be construed as legal or compliance advice. CVSS scores and severity ratings reflect industry standards but may not capture your organization's unique risk context. Always verify patch availability and compatibility against the official vendor advisories before deploying updates. SEC.co makes no warranties regarding the completeness or accuracy of vulnerability intelligence and recommends independent security review of all patches and mitigations. Source: NVD (public-domain), retrieved 2026-08-03. Analysis generated by SEC.co (claude-haiku-4-5).
Related vulnerabilities
- CVE-2026-57436MEDIUMNokogiri XML/HTML Library Use-After-Free Vulnerability
- CVE-2026-57437MEDIUMNokogiri XPathContext Use-After-Free Memory Safety Vulnerability
- CVE-2026-57236HIGHNokogiri Use-After-Free in Document Encoding (CVSS 8.2)
- CVE-2026-57435HIGHNokogiri XML Attribute Memory Corruption (DoS)
- CVE-2025-55644MEDIUMHeap Use-After-Free in GPAC MP4Box v2.4 DoS Vulnerability
- CVE-2025-55650MEDIUMHeap Use-After-Free in GPAC MP4Box v2.4 DoS Vulnerability
- CVE-2025-60466MEDIUMGPAC MP4Box Use-After-Free DoS Vulnerability
- CVE-2025-60471MEDIUMUse-After-Free in GPAC MP4Box Before 26.02.0 Denial of Service