Skip to main content

Nokogiri CVE-2026-57436

| EUVDEUVD-2026-39427 LOW
Use After Free (CWE-416)
2026-06-25 GitHub_M
1.7
CVSS 4.0 · Vendor: GitHub_M
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Application code assigns DTD node to Document#root=
  2. Delivery
    libxml2 internal xmlDoc state becomes inconsistent
  3. Exploit
    Ruby GC triggers finalization of Nokogiri document object
  4. Execution
    libxml2 dereferences freed or mistyped node pointer
  5. Persist
    Heap use-after-free causes invalid memory read or segfault
  6. Impact
    Ruby process crashes

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 that application code explicitly calls Nokogiri::XML::Document#root= with a non-element node - specifically a DTD node or any other Nokogiri::XML::Node subclass that is not an element node - in the CRuby implementation of Nokogiri prior to 1.19.4. This cannot be triggered by untrusted user input (e.g., maliciously crafted XML documents), by normal API usage, or by any network-reachable code path absent a pre-existing programming error in the application. The JRuby runtime is entirely unaffected. What limits exploitation further: the crash (segfault or invalid memory read) occurs during garbage collection or finalization, not deterministically at the assignment, making it difficult to construct a reliable exploit even in the erroneous code scenario. The attacker model here is effectively a developer writing incorrect application code, not an external adversary.

Impact

Real-world risk is very low, consistent with the CVSS 4.0 score of 1.7. The critical limiting factor confirmed by the vendor is that this vulnerability cannot be triggered by untrusted input or through correct API usage - it requires a programming error in application code where a DTD node is explicitly passed to Document#root=. The CVSS 4.0 vector's AT:P (attack requirements present) captures this constraint: a specific non-default, incorrect code pattern must exist in the consuming application. Availability impact is Low (VA:L), with no confidentiality or integrity impact (VC:N/VI:N). The E:U (unexploited) signal reinforces that no exploitation attempt has been observed. There is no KEV listing and no public exploit identified. The risk profile is effectively that of a latent crash bug in applications that misuse the API, rather than an externally exploitable attack surface. Security teams should prioritize this as a routine gem upgrade during normal dependency maintenance, not an emergency response item.

Exploit ScenarioDerived

A Ruby application using Nokogiri on CRuby parses an XML document and, due to a developer error, extracts the DTD node from the document and assigns it as the root via document.root = document.internal_subset. At some subsequent point - possibly during a request cycle's cleanup, process shutdown, or garbage collection run - Ruby's GC finalizes the document object, libxml2 attempts to free the DTD node through the root pointer, and the process crashes with a segfault or accesses already-freed heap memory. No public exploit code exists; the scenario requires attacker-controlled application code rather than attacker-controlled input data.

Monitor Track and reassess. Why: LOW severity (CVSS 0.1-3.9).
Patch available 0.3% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – Jun 25, 2026

Heap use-after-free in Nokogiri's CRuby implementation (prior to 1.19.4) can corrupt process memory when application code assigns a DTD node as a document root via Document#root=. The root cause is insufficient type validation in the setter, which accepted any Nokogiri::XML::Node subclass rather than restricting to element nodes, leaving libxml2 in an inconsistent internal state that triggers a dangling pointer dereference during Ruby garbage collection or finalization. No active exploitation is confirmed (not in CISA KEV), no public exploit is identified, and the Nokogiri maintainers rate this low severity; the CVSS 4.0 score of 1.7 with E:U corroborates that assessment.

RemediationAI

Upgrade Nokogiri to version 1.19.4 or later; this is the vendor-confirmed patch (GHSA-wjv4-x9w8-wm3h at https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-wjv4-x9w8-wm3h). Version 1.19.4 changes Document#root= to raise TypeError for any non-element node, preventing the invalid libxml2 state from being created. For applications that cannot upgrade immediately, the workaround is to audit all call sites of Document#root= and enforce that only element nodes (Nokogiri::XML::Element) are assigned; passing DTD nodes, comment nodes, processing instruction nodes, or other non-element types must be prevented at the application layer. This workaround requires a code audit and is inherently incomplete if call sites are not fully enumerated, so upgrading to 1.19.4 is strongly preferred. No side effects from the patch have been noted; the TypeError behavior is a stricter, safer contract for a method that previously silently accepted invalid input.

Affected VersionsENISA

nokogiri < 1.19.4

Affected Packages

rubygems nokogiri fix: 1.19.4

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 Ruby gem that wraps libxml2 (for the CRuby/MRI runtime) and Xerces (for JRuby) to provide XML and HTML parsing. The vulnerability is isolated to the CRuby/libxml2 backend (CPE: cpe:2.3:a:sparklemotion:nokogiri:*:*:*:*:*:*:*:*). The Nokogiri::XML::Document#root= setter validated its argument only as an instance of Nokogiri::XML::Node, a broad base class that includes DTD nodes (Nokogiri::XML::DTD), processing instruction nodes, and others. When a DTD node is assigned as the root, libxml2's internal xmlDoc structure holds a pointer to a node type that is invalid in that slot. During Ruby object finalization or garbage collection, libxml2's cleanup routines dereference or free this node, resulting in a CWE-416 heap use-after-free: the pointer refers to memory that has already been freed, causing an invalid memory read or, in the worst case, a segfault that crashes the Ruby process. The JRuby implementation was not vulnerable because it uses a separate code path, though the same input validation was added there for behavioral parity.

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

Vendor (GitHub_M) PRIMARY 1.7 LOW
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
vuln.today AI 1.9 LOW

Requires ability to write and deploy application code with the specific API misuse (PR:H, AV:L, AC:H); only availability impact applies.

3.1 AV:L/AC:H/PR:H/UI:N/S:U/C:N/I:N/A:L
4.0 AV:L/AC:H/AT:P/PR:H/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N

Primary rating from Vendor (GitHub_M).

CVSS VectorVendor: GitHub_M

Attack Vector
Network
Attack Complexity
Low
Attack Requirements
Present
Privileges Required
None
User Interaction
None
Vulnerable system: Confidentiality
None
Vulnerable system: Integrity
None
Vulnerable system: Availability
Low
Subsequent system: Confidentiality
None
Subsequent system: Integrity
None
Subsequent system: Availability
None

Lifecycle Timeline

1
Patch available
Jun 25, 2026 - 16:03 EUVD

DescriptionCVE.org

Nokogiri is an open source XML and HTML library for the Ruby programming language. Prior to 1.19.4, Nokogiri::XML::Document#root= validated only that the new root was a Nokogiri::XML::Node, allowing a DTD node to be set as the document root. The result is a heap use-after-free during garbage collection or finalization, leading to an invalid memory read or potentially a segfault. This vulnerability is fixed in 1.19.4.

Threat Intelligence Overview

EPSS Score
0.3%
Top 75% exploitable
Prevalence
High
core Ruby XML/HTML parsing dependency in many Rails and Ruby applications
Data Quality
7 sources
Confidence: High
EUVD NVD CVE.org EPSS Vulnrichment MSRC GitHub VulDB

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.

SignalValue
Severity LOW
CISA KEV No
Public POC No
EPSS 0.3%
Patch available Yes
Active threat No
Deciding rule
LOW severity (CVSS 0.1-3.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation
None
System Exposure· derived
Open
Automatable
Yes
Human Impact· derived
High
Technical Impact
Total

Priority Score

8
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +8
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

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.

CVE-2022-29181 HIGH POC
8.2 May 20

Nokogiri is an open source XML and HTML library for Ruby. Rated high severity (CVSS 8.2), this vulnerability is remotely

CVE-2019-5477 CRITICAL
9.8 Aug 16

A command injection vulnerability in Nokogiri v1.10.3 and earlier allows commands to be executed in a subprocess via Rub

CVE-2026-79770 HIGH
8.7 Aug 25

Denial-of-service in Nokogiri before 1.19.3 stems from three distinct ReDoS vulnerabilities in the CSS selector tokenize

CVE-2026-79769 HIGH
8.7 Aug 25

Out-of-bounds memory read in Nokogiri (CRuby) versions before 1.19.4 crashes the host Ruby process when application code

CVE-2022-23476 HIGH
7.5 Dec 08

Nokogiri is an open source XML and HTML library for the Ruby programming language. Rated high severity (CVSS 7.5), this

CVE-2022-24836 HIGH
7.5 Apr 11

Nokogiri is an open source XML and HTML library for Ruby. Rated high severity (CVSS 7.5), this vulnerability is remotely

CVE-2021-41098 HIGH
7.5 Sep 27

Nokogiri is a Rubygem providing HTML, XML, SAX, and Reader parsers with XPath and CSS selector support. Rated high sever

CVE-2026-79771 MEDIUM
6.9 Aug 25

Heap memory leaks in Nokogiri's XSLT transform method (versions before 1.19.3) enable gradual denial of service against

CVE-2026-79772 MEDIUM
6.9 Aug 25

Unchecked return value in Nokogiri's CRuby extension (versions 1.5.1 through 1.19.0) causes the `canonicalize` method to

CVE-2026-57235 MEDIUM
6.3 Jun 25

Out-of-bounds read in Nokogiri's `NodeSet#[]` method (all versions before 1.19.4) enables an attacker who can supply a l

CVE-2020-26247 MEDIUM
4.3 Dec 30

Nokogiri is a Rubygem providing HTML, XML, SAX, and Reader parsers with XPath and CSS selector support. Rated medium sev

CVE-2026-57234 LOW
2.6 Jun 25

NONET network restriction bypass in Nokogiri's JRuby implementation permits external resource fetching during XML Schema

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy