Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessSupply null-byte or non-string encoding value to Document#encoding=
-
Deliverylibxml2 C extension frees internal encoding string pointer
-
ExploitRuby exception raised before pointer is replaced
-
ExecutionApplication rescues exception and retains document reference
-
PersistSubsequent Document#encoding call dereferences freed memory
-
ImpactSegfault (process crash) or stale heap bytes leak into Ruby String
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 | Three specific conditions must align simultaneously for exploitation: (1) the application must pass an attacker-controlled or otherwise invalid encoding value - specifically a non-string or a string containing a null byte - to Document#encoding= on a Nokogiri XML document; (2) the application must rescue the resulting Ruby exception rather than allowing it to propagate, terminate the operation, or replace the document; and (3) the application must subsequently call Document#encoding on the same, now-corrupted document object. Applications that pass only developer-authored, hardcoded encoding strings are not exposed. Applications that do not rescue the Document#encoding= exception and continue using the document are not exposed. JRuby-based Nokogiri installations are immune regardless of usage pattern. |
| Impact | The provided CVSS 4.0 score of 1.7 (AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L) is broadly accurate, with the AT:P (attack requirements: present) metric correctly capturing the non-default exploitation preconditions. Real-world risk is very low: the Nokogiri maintainers themselves rate it low severity and describe the triggering pattern as unusual. No KEV listing confirms active exploitation, no public POC has been identified, and no EPSS score was provided in the input data. The network attack vector (AV:N) reflects that a remote attacker who controls parsing input could theoretically reach this code path, but only if the application also rescues the exception and reuses the document - a pattern that does not arise during normal Nokogiri use. The primary realistic impact is a process crash (availability) rather than meaningful information disclosure, as heap byte leaks via this path are limited in scope. This is a patch-and-move-on issue with no urgency for emergency remediation in most environments. |
| Exploit ScenarioDerived | An attacker who controls input to a Ruby application that passes user-supplied data to Document#encoding= can submit a null-byte-containing string, causing the method to free the internal encoding pointer and raise a Ruby exception. If the application rescues this exception and continues using the same document object - for example, in an error-tolerant document processing pipeline - the next call to Document#encoding reads freed heap memory, either crashing the Ruby process or returning stale heap bytes as a string value. No public proof-of-concept code has been identified at time of analysis. |
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 (libxml2) implementation allows freed heap memory to be read on subsequent calls to Document#encoding, potentially causing a segmentation fault or leaking stale heap bytes into a Ruby String object. Versions prior to 1.19.4 are affected when the three-step exploitation pattern occurs: an invalid encoding assignment, exception rescue, and continued document use. No public exploit has been identified and this vulnerability is not listed in CISA KEV; the CVSS 4.0 score of 1.7 accurately reflects the low real-world priority.
RemediationAI
Upgrade to Nokogiri 1.19.4 or later; this is the vendor-released patch (confirmed by GHSA-5v8h-3h3q-446p) and requires no changes to application-level public API usage. If an immediate upgrade is not possible, the primary compensating control is to avoid passing attacker-controlled or externally sourced values to Document#encoding= - applications that exclusively assign hardcoded, developer-authored encoding strings to this method are not directly exposed to the vulnerability. Additionally, audit any rescue blocks that catch exceptions from Document#encoding= and continue operating on the same document object; restructuring such code to discard and recreate the document after an encoding error eliminates the dangling-pointer exploitation path without requiring a gem update. The vendor advisory is at https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-5v8h-3h3q-446p.
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 (CPE: cpe:2.3:a:sparklemotion:nokogiri) is a widely used Ruby gem wrapping libxml2 for XML and HTML parsing. The vulnerability is classified as CWE-416 (Use After Free): the C extension's implementation of Document#encoding= frees the libxml2 document's internal encoding C string when an invalid value is passed, but fails to zero out or replace the pointer before raising a Ruby exception. This leaves a dangling pointer in the document's internal state. The next call to Document#encoding then dereferences freed heap memory, which can either trigger a segmentation fault (crashing the Ruby process) or return stale freed bytes as a Ruby String, constituting a partial heap information disclosure. The flaw is specific to the CRuby path because it lives in the C extension; Nokogiri's JRuby implementation uses a Java-based XML stack and does not share this code path.
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
AC:H captures the three-step exploitation chain; C:L reflects the potential heap byte leak noted in the advisory and information disclosure tag.
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, calling Document#encoding= with an invalid encoding (e.g., a non-string, or a string containing a null byte) raises an exception, but only after freeing the document's current encoding string without replacing it. The document is left referencing freed memory, so the next call to Document#encoding reads invalid memory, which can cause a segfault or leak freed bytes into a Ruby String. Affects the CRuby (libxml2) implementation only; JRuby is not affected. 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-39419
NVD
CVE.org
EPSS
Vulnrichment
GitHub
VulDB
Exploit-DB