GHSA-wfpw-mmfh-qq69: Nokogiri Possible Use-After-Free Vulnerability

LOW
CWE-416
Published
Advisory Summary

GHSA-wfpw-mmfh-qq69 is a LOW possible use-after-free vulnerability (CWE-416: Use After Free) affecting Nokogiri libraries in the RubyGems ecosystem. The issue involves possible use-after-free in xinclude processing. Remediation is available by upgrading affected packages to version 1.19.4.

GHSA-wfpw-mmfh-qq69 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-wfpw-mmfh-qq69
Severity LOW
CVSS v3.1 Base Score N/A
CWE Classification CWE-416: Use After Free
Affected Product Nokogiri
Package Ecosystem RubyGems
Published Date
Last Updated

How to Fix GHSA-wfpw-mmfh-qq69

To remediate this vulnerability, upgrade all affected Nokogiri dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

nokogiri fixed: 1.19.4
Upgrade nokogiri to 1.19.4
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for nokogiri

How to Check if You Are Affected

To determine whether your application is affected by GHSA-wfpw-mmfh-qq69, inspect your project dependencies for Nokogiri:

inspect dependencies for nokogiri

Analyze the terminal output to locate any version of Nokogiri in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.19.4), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-416: Use After Free, where the product reuses or references memory after it has been freed. at some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. any operations using the original pointer are no longer valid because the memory "belongs" to the code that operates on the new pointer. In Nokogiri, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary 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. Nokogiri 1.19.4 substitutes each `<xi:include>` on a defensive copy by default, so the structures libxml2 frees are never the ones bound to live Ruby objects. Only the CRuby implementation is affected; JRuby is not affected. ### Severity The Nokogiri maintainers have evaluated this as low severity. Reaching it requires an unusual API-usage pattern that does not arise during normal use. The application must parse a document without XInclude, traverse into an `<xi:include>` subtree to expose its nodes or namespaces to Ruby, and only then invoke XInclude processing. The common case, requesting XInclude at parse time, operates on a freshly parsed document whose nodes are not yet exposed to Ruby and is not affected. Nokogiri 1.19.4 makes this pattern safe by default and requires no change to application code. ### Mitigation Upgrade to Nokogiri 1.19.4 or later. As a workaround for earlier versions, perform XInclude substitution at parse time (with the `xinclude` parse option) rather than calling `#do_xinclude` on a document that has already been traversed. A freshly parsed document has no nodes exposed to Ruby, so the substitution is safe. ### Credit This issue was responsibly reported by Zheng Yu from depthfirst.com.

GHSA-wfpw-mmfh-qq69 Affected Nokogiri Versions

1 component(s)
Fixed Versions:
1.19.4
Product / Package Ecosystem Affected Versions Fixed Version
nokogiri
RubyGems
< 1.19.4
1.19.4

References

Frequently Asked Questions

What is GHSA-wfpw-mmfh-qq69?
GHSA-wfpw-mmfh-qq69 is a security vulnerability in Nokogiri involving Possible Use-After-Free in XInclude Processing under CWE-416: Use After Free.
Which Nokogiri versions are affected?
Affected versions include releases prior to 1.19.4 across affected packages: nokogiri.
What version fixes GHSA-wfpw-mmfh-qq69?
Upgrading to 1.19.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is nokogiri affected?
Yes, nokogiri is affected in releases prior to 1.19.4. Upgrade your dependency to 1.19.4 or later.
What CWE is associated with GHSA-wfpw-mmfh-qq69?
GHSA-wfpw-mmfh-qq69 is classified under CWE-416: Use After Free (The product reuses or references memory after it has been freed. At some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. Any operations using the original pointer are no longer valid because the memory "belongs" to the code that operates on the new pointer.).
How can I check RubyGems dependencies for GHSA-wfpw-mmfh-qq69?
Run the dependency tree command: 'inspect dependencies for nokogiri'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-wfpw-mmfh-qq69",
  "modified" : "2026-06-19T16:37:25Z",
  "published" : "2026-06-19T16:37:25Z",
  "aliases" : [ ],
  "summary" : "Nokogiri: Possible Use-After-Free in XInclude Processing",
  "details" : "### Summary\n\nXInclude 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.\n\nNokogiri 1.19.4 substitutes each `<xi:include>` on a defensive copy by default, so the structures libxml2 frees are never the ones bound to live Ruby objects.\n\nOnly the CRuby implementation is affected; JRuby is not affected.\n\n### Severity\n\nThe Nokogiri maintainers have evaluated this as low severity. Reaching it requires an unusual API-usage pattern that does not arise during normal use. The application must parse a document without XInclude, traverse into an `<xi:include>` subtree to expose its nodes or namespaces to Ruby, and only then invoke XInclude processing. The common case, requesting XInclude at parse time, operates on a freshly parsed document whose nodes are not yet exposed to Ruby and is not affected. Nokogiri 1.19.4 makes this pattern safe by default and requires no change to application code.\n\n### Mitigation\n\nUpgrade to Nokogiri 1.19.4 or later.\n\nAs a workaround for earlier versions, perform XInclude substitution at parse time (with the `xinclude` parse option) rather than calling `#do_xinclude` on a document that has already been traversed. A freshly parsed document has no nodes exposed to Ruby, so the substitution is safe.\n\n### Credit\n\nThis issue was responsibly reported by Zheng Yu from depthfirst.com.",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "nokogiri"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.19.4"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-wfpw-mmfh-qq69"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/sparklemotion/nokogiri"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-416" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-06-19T16:37:25Z",
    "nvd_published_at" : null
  }
}