Listen to this Post
The vulnerability exists in the `Nokogiri::XML::NodeSet[]` method (and its alias slice). When an index is provided, the method checks whether the index is within the bounds of the node set. However, this bounds check is performed using a 32-bit-truncated copy of the supplied index. For a large negative index (e.g., a value less than -2³¹), the truncation produces a different, smaller negative number that passes the bounds check. After the check passes, the original full-width (64-bit) index is used to access the underlying storage. This causes the read to occur at an address far outside the allocated node set memory. On CRuby, this out-of-bounds read typically results in a segmentation fault and process crash, constituting a denial-of-service condition. In some cases, the read may access adjacent memory that contains sensitive data, leading to potential memory disclosure. On JRuby, the issue does not cause memory unsafety but instead results in the method returning an incorrect node object. Nokogiri 1.19.4 corrects the flaw by performing the bounds check against the full-width index, eliminating the truncation step. Exploitation requires that an application passes an attacker-controlled integer to `NodeSet[]` – for example, parsing user input and using it directly as an array index without validation. The vulnerability is rated as medium severity by the Nokogiri maintainers. The issue was responsibly reported by Zheng Yu from depthfirst.com.
DailyCVE Form:
Platform: ……. Nokogiri (CRuby)
Version: …….. < 1.19.4
Vulnerability :…… Out-of-bounds read
Severity: ……. Medium
date: ………. 2026-06-18
Prediction: …… 2026-06-18 (already patched)
What Undercode Say:
Check installed Nokogiri version gem list nokogiri Upgrade to patched version gem install nokogiri -v 1.19.4 In Bundler environment, update Gemfile: gem 'nokogiri', '>= 1.19.4' bundle update nokogiri
Vulnerable code pattern – index comes from user input index = params[:index].to_i node = node_set[bash] CVE-2026-XXXX if index is a large negative integer Safe validation workaround before upgrading index = params[:index].to_i if index.abs < node_set.length node = node_set[bash] else handle out-of-bounds safely end
Exploit:
An attacker supplies a large negative integer, e.g., -999999999999999999, as the index to NodeSet[]. The 32-bit truncated check passes, but the full 64-bit value is used for memory access, causing a crash or memory read beyond the node set boundary.
Protection:
- Upgrade to Nokogiri 1.19.4 or later.
- Validate all externally-supplied indices against `node_set.length` before use.
- Avoid passing untrusted integers as indices to
NodeSet[].
Impact:
- Denial of Service: Process crash on CRuby.
- Memory Disclosure: Potential exposure of adjacent memory contents on CRuby.
- Incorrect Behavior: On JRuby, the method returns an incorrect node, which may lead to logic errors in applications that rely on the returned value.
🎯Let’s Practice Exploiting & Learn Patching For Free:
🎓 Live Courses & Certifications:
Join Undercode Academy for Verified Certifications
🚀 Request a Custom Project:
Secure, high-velocity infrastructure and disruptive technological engineering. Contact our engineering team for high-tier development and proprietary systems:
[email protected]
💎 Smart Architecture | 🛡️ Secure by Design | ⭐ Trusted by Thousands
Sources:
Reported By: github.com
Extra Source Hub:
Undercode

