CVE-2026-57235
JSON

6.3medium

Nokogiri: Possible Out-of-Bounds Read in `Nokogiri::XML::NodeSet#[]`

Severity
6.3medium CVSS:4.0 by GitHub_M
Exploit likelihood
0.34% (higher than 29% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-5prr-v3j2-97mh

Description

Nokogiri is an open source XML and HTML library for the Ruby programming language. Prior to 1.19.4, Nokogiri::XML::NodeSet#[] (and its alias #slice) checked the requested index against the node set's bounds using a 32-bit-truncated copy of the index. A large negative index could pass the check and then be used at full width, reading outside the node set's storage. On CRuby this is an out-of-bounds read that typically crashes the process; on JRuby it is not memory-unsafe but returns an incorrect node. This vulnerability is fixed in 1.19.4.

Affected

Product or packageVersionsReported by
sparklemotion nokogiri< 1.19.4CVE List
nokogiri (RubyGems)before 1.19.4GitHub Advisory Database
nokogiri nokogiribefore 1.19.4NVD

All scores

GitHub_M6.3medium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:N/VA:L/SC:N/SI:N/SA:N
GitHubmedium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:N/VA:L/SC:N/SI:N/SA:N
NVD8.2high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:H

Classification

CWE-125CWE-190

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

Nokogiri is an open source XML and HTML library for the Ruby programming language. Prior to 1.19.4, Nokogiri::XML::NodeSet#[] (and its alias #slice) checked the requested index against the node set's bounds using a 32-bit-truncated copy of the index. A large negative index could pass the check and then be used at full width, reading outside the node set's storage. On CRuby this is an out-of-bounds read that typically crashes the process; on JRuby it is not memory-unsafe but returns an incorrect node. This vulnerability is fixed in 1.19.4.

GitHub Advisory Database
Summary

Nokogiri::XML::NodeSet#[] (and its alias #slice) checked the requested index against the node set's bounds using a 32-bit-truncated copy of the index. A large negative index could pass the check and then be used at full width, reading outside the node set's storage. On CRuby this is an out-of-bounds read that typically crashes the process; on JRuby it is not memory-unsafe but returns an incorrect node.

Nokogiri 1.19.4 performs the bounds check against the full-width index.

Severity

The Nokogiri maintainers have evaluated this as medium severity.

Exploitation requires an application to pass an attacker-controlled integer to NodeSet#[]. The primary impact is a controlled crash (denial of service), with potential for memory disclosure on CRuby.

On JRuby, Nokogiri is not affected by this vulnerability.

Mitigation

Upgrade to Nokogiri 1.19.4 or later.

As a workaround, applications that index a NodeSet with externally-supplied integers can validate the index against node_set.length before use, or avoid passing untrusted values as an index.

Credit

This issue was responsibly reported by Zheng Yu from depthfirst.com.

NVD (es)

Nokogiri es una biblioteca XML y HTML de código abierto para el lenguaje de programación Ruby. Anteriormente a la 1.19.4, Nokogiri::XML::NodeSet#[] (y su alias #slice) verificaba el índice solicitado contra los límites del conjunto de nodos utilizando una copia truncada a 32 bits del índice. Un índice negativo grande podía pasar la verificación y luego ser utilizado a ancho completo, leyendo fuera del almacenamiento del conjunto de nodos. En CRuby, esto es una lectura fuera de límites que típicamente bloquea el proceso; en JRuby, no es inseguro para la memoria, pero devuelve un nodo incorrecto. Esta vulnerabilidad se ha corregido en la versión 1.19.4.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-57235 changed 2026-06-25CVE Terms of Use
GitHub Advisory DatabaseGHSA-5prr-v3j2-97mh changed 2026-09-10CC-BY-4.0
NVDCVE-2026-57235 changed 2026-10-25Public domain