Advisory Database
  • Advisories
  • Dependency Scanning
  1. gem
  2. ›
  3. nokogiri
  4. ›
  5. GHSA-p67v-3w7g-wjg7

GHSA-p67v-3w7g-wjg7: Nokogiri: Possible Use-After-Free when directly using `NokogirI::XML::XPathContext` beyond document lifetime

June 19, 2026

Nokogiri::XML::XPathContext did not keep its source document alive for garbage collection. If an XPathContext outlived its document and the document was collected, evaluating an XPath expression could read invalid memory and potentially segfault.

This is only reachable when application code constructs an XPathContext directly and lets the document become unreachable while continuing to use the context. The normal Document#xpath, #css, and related search methods are not affected, and it is not triggerable by malicious document input.

Nokogiri 1.19.4 makes XPathContext keep its source document alive for as long as the context exists.

Only the CRuby implementation is affected. JRuby is not affected.

References

  • github.com/advisories/GHSA-p67v-3w7g-wjg7
  • github.com/sparklemotion/nokogiri/security/advisories/GHSA-p67v-3w7g-wjg7

Code Behaviors & Features

Detect and mitigate GHSA-p67v-3w7g-wjg7 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions before 1.19.4

Fixed versions

  • 1.19.4

Solution

Upgrade to version 1.19.4 or above.

Impact 5.3 MEDIUM

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L

Learn more about CVSS

Weakness

  • CWE-416: Use After Free

Source file

gem/nokogiri/GHSA-p67v-3w7g-wjg7.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Tue, 23 Jun 2026 12:24:18 +0000.