Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessApplication directly constructs XPathContext from document
-
DeliveryDocument variable falls out of scope
-
ExploitRuby GC collects and frees document memory
-
ExecutionApplication invokes XPathContext to evaluate XPath
-
PersistC extension dereferences freed document pointer
-
ImpactProcess segfaults
Vulnerability Assessment
| Weakness |
CWE
ASVS 5.0
V15 - Secure Coding and Architecture Memory lifecycle management
MITRE ATT&CK
2 techniques across 2 tactics: Execution, Privilege Escalation The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up. |
| Exploitation Conditions | Exploitation requires two simultaneous application-level conditions: (1) the application code must directly instantiate |
| Impact | The CVSS 4.0 vector CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N/E:U/U:Clear scores 1.7, and the AT:P (specific attack requirements) metric accurately captures the non-default API pattern necessary to reach the vulnerable code path. There is no confidentiality or integrity impact - only a low availability impact (VA:L) in the form of a potential application segfault. No EPSS score was provided; given the restrictive triggering conditions and E:U (no known exploit), exploitation probability is inferred to be negligible. This is not in CISA KEV. The Nokogiri maintainers themselves evaluated this as low severity. This is best characterized as a library hardening fix: the risk to any given deployment is real only if developers have written code that directly mismanages XPathContext lifecycle, which the vendor describes as an unusual pattern absent from normal use. This is a real-world near-zero-priority issue for the vast majority of Nokogiri consumers. |
| Exploit ScenarioDerived | A Ruby application directly instantiates |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – Jun 25, 2026
Use-after-free in Nokogiri's CRuby implementation (versions prior to 1.19.4) allows an application crash via segfault when an XML::XPathContext object outlives its source document and that document is freed by Ruby's garbage collector. Only CRuby is affected; JRuby is not. This is not triggerable by malicious document input and cannot be reached through the standard Document#xpath, #css, or related methods - it requires an unusual direct API usage pattern in application code. No public exploit has been identified, this is not listed in CISA KEV, and the CVSS 4.0 score of 1.7 reflects the tightly constrained triggering conditions.
RemediationAI
Vendor-released patch: 1.19.4. Upgrade the nokogiri gem to version 1.19.4 or later, which causes XPathContext to hold a GC reference to its source document for the duration of the context's lifetime, eliminating the use-after-free with no breaking changes to the public API. See the advisory at https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-p67v-3w7g-wjg7 for release details. For deployments that cannot immediately upgrade, the effective workaround is to ensure any Ruby variable referencing the source document remains in scope and reachable for the full lifetime of any Nokogiri::XML::XPathContext constructed from it. Applications using only the standard Document#xpath, #css, #search, and related methods require no action, as those methods already maintain the document reference internally and are entirely unaffected.
Affected VersionsENISA
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 1 package in rubygems
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
Nokogiri is a widely used Ruby gem wrapping libxml2 and libxslt for XML and HTML parsing and XPath querying. CWE-416 (Use After Free) manifests in Nokogiri's C extension layer: Nokogiri::XML::XPathContext wraps libxml2's xmlXPathContextPtr and, prior to 1.19.4, held a raw C pointer to its source document without registering a GC reference. Ruby's mark-and-sweep garbage collector could therefore free the underlying document object while the XPathContext retained a dangling pointer. A subsequent XPath evaluation dereferences that freed memory, producing undefined behavior or a segfault. The fix in 1.19.4 roots the source document against GC for the full lifetime of the XPathContext. JRuby is unaffected because its XML implementation does not share this C-extension memory management model. Affected CPE: cpe:2.3:a:sparklemotion:nokogiri:*:*:*:*:*:*:*:*.
Know when Nokogiri gets its next vulnerability
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N/E:U/U:Clear
AC:H captures the non-default direct-XPathContext API misuse and GC timing required; only low availability impact applies via potential segfault.
Primary rating from Vendor (GitHub_M).
CVSS VectorVendor: GitHub_M
Lifecycle Timeline
1DescriptionCVE.org
Nokogiri is an open source XML and HTML library for the Ruby programming language. Prior to 1.19.4, 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. This vulnerability is fixed in 1.19.4.
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
Use-after-free vulnerabilities occur when a program continues to access memory through a pointer after that memory has been deallocated.
Memory corruption occurs when a program writes data beyond the boundaries of allocated memory regions or accesses memory in unintended ways, violating the integrity of the process's address space.
Information disclosure occurs when an application unintentionally exposes sensitive data that aids attackers in reconnaissance or directly compromises security.
Nokogiri is an open source XML and HTML library for Ruby. Rated high severity (CVSS 8.2), this vulnerability is remotely
A command injection vulnerability in Nokogiri v1.10.3 and earlier allows commands to be executed in a subprocess via Rub
Denial-of-service in Nokogiri before 1.19.3 stems from three distinct ReDoS vulnerabilities in the CSS selector tokenize
Out-of-bounds memory read in Nokogiri (CRuby) versions before 1.19.4 crashes the host Ruby process when application code
Nokogiri is an open source XML and HTML library for the Ruby programming language. Rated high severity (CVSS 7.5), this
Nokogiri is an open source XML and HTML library for Ruby. Rated high severity (CVSS 7.5), this vulnerability is remotely
Nokogiri is a Rubygem providing HTML, XML, SAX, and Reader parsers with XPath and CSS selector support. Rated high sever
Heap memory leaks in Nokogiri's XSLT transform method (versions before 1.19.3) enable gradual denial of service against
Unchecked return value in Nokogiri's CRuby extension (versions 1.5.1 through 1.19.0) causes the `canonicalize` method to
Out-of-bounds read in Nokogiri's `NodeSet#[]` method (all versions before 1.19.4) enables an attacker who can supply a l
Nokogiri is a Rubygem providing HTML, XML, SAX, and Reader parsers with XPath and CSS selector support. Rated medium sev
NONET network restriction bypass in Nokogiri's JRuby implementation permits external resource fetching during XML Schema
EUVD-2026-39428
NVD
CVE.org
EPSS
Vulnrichment
GitHub
VulDB
Exploit-DB