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 package | Versions | Reported by |
|---|---|---|
| sparklemotion nokogiri | < 1.19.4 | CVE List |
| nokogiri (RubyGems) | before 1.19.4 | GitHub Advisory Database |
| nokogiri nokogiri | before 1.19.4 | NVD |
All scores
| GitHub_M | 6.3medium CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:N/VA:L/SC:N/SI:N/SA:N |
| GitHub | medium CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:N/VA:L/SC:N/SI:N/SA:N |
| NVD | 8.2high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:H |
Classification
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
| https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-5prr-v3j2-97mh | mitigation, vendor-advisory, web | |
| https://github.com/sparklemotion/nokogiri | package | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-57235 changed 2026-06-25 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-5prr-v3j2-97mh changed 2026-09-10 | CC-BY-4.0 |
| NVD | CVE-2026-57235 changed 2026-10-25 | Public domain |