Nokogiri: Possible Out-of-Bounds Read in `Nokogiri::XML::NodeSet#[]`
Key facts
- Attack vector
- —
- Privileges required
- —
- User interaction
- —
- Attack complexity
- —
- Impact type
- —
- Confidentiality · integrity · availability
- —
- Fix status
- Fixed
No CVSS vector from any source. Fix status from GitHub.
Summary
### 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.
Why it matters now
SSVC decision points
Not available: CISA has not published SSVC decision points for this record.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| — | nokogiri (RubyGems) | before 1.19.4 | 1.19.4 | Patch available | GHSA-5prr-v3j2-97mh |
- nokogiri (RubyGems) Vendor— Affected before 1.19.4 Fixed in 1.19.4 Patch available GHSA-5prr-v3j2-97mh
Remediation
- Fix · GHSA-5prr-v3j2-97mh nokogiri (RubyGems) Fixed in 1.19.4 Advisory →
Timeline
- 2026-10-03 Threatist record created from GHSA-5prr-v3j2-97mh
References
Sources
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences