GHSA-5prr-v3j2-97mh: Nokogiri Possible Out-of-Bounds Read Vulnerability

MODERATE
CWE-190 CWE-125
Published
Advisory Summary

GHSA-5prr-v3j2-97mh is a MODERATE possible out-of-bounds read vulnerability (CWE-190: Integer Overflow or Wraparound) affecting Nokogiri libraries in the RubyGems ecosystem. The issue involves possible out-of-bounds read in `nokogiri::xml::nodeset#[]`. Remediation is available by upgrading affected packages to version 1.19.4.

GHSA-5prr-v3j2-97mh at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-5prr-v3j2-97mh
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-190: Integer Overflow or Wraparound
Affected Product Nokogiri
Package Ecosystem RubyGems
Published Date
Last Updated

How to Fix GHSA-5prr-v3j2-97mh

To remediate this vulnerability, upgrade all affected Nokogiri dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

nokogiri fixed: 1.19.4
Upgrade nokogiri to 1.19.4
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for nokogiri

How to Check if You Are Affected

To determine whether your application is affected by GHSA-5prr-v3j2-97mh, inspect your project dependencies for Nokogiri:

inspect dependencies for nokogiri

Analyze the terminal output to locate any version of Nokogiri in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.19.4), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-190: Integer Overflow or Wraparound, where the product performs a calculation that can produce an integer overflow or wraparound when the logic assumes that the resulting value will always be larger than the original value. this occurs when an integer value is incremented to a value that is too large to store in the associated representation. when this occurs, the value may become a very small or negative number. In Nokogiri, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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.

GHSA-5prr-v3j2-97mh Affected Nokogiri Versions

1 component(s)
Fixed Versions:
1.19.4
Product / Package Ecosystem Affected Versions Fixed Version
nokogiri
RubyGems
< 1.19.4
1.19.4

References

Frequently Asked Questions

What is GHSA-5prr-v3j2-97mh?
GHSA-5prr-v3j2-97mh is a security vulnerability in Nokogiri involving Possible Out-of-Bounds Read in `Nokogiri::XML::NodeSet#[]` under CWE-190: Integer Overflow or Wraparound.
Which Nokogiri versions are affected?
Affected versions include releases prior to 1.19.4 across affected packages: nokogiri.
What version fixes GHSA-5prr-v3j2-97mh?
Upgrading to 1.19.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is nokogiri affected?
Yes, nokogiri is affected in releases prior to 1.19.4. Upgrade your dependency to 1.19.4 or later.
What CWE is associated with GHSA-5prr-v3j2-97mh?
GHSA-5prr-v3j2-97mh is classified under CWE-190: Integer Overflow or Wraparound (The product performs a calculation that can produce an integer overflow or wraparound when the logic assumes that the resulting value will always be larger than the original value. This occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may become a very small or negative number.).
How can I check RubyGems dependencies for GHSA-5prr-v3j2-97mh?
Run the dependency tree command: 'inspect dependencies for nokogiri'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-5prr-v3j2-97mh",
  "modified" : "2026-06-19T16:36:42Z",
  "published" : "2026-06-19T16:36:42Z",
  "aliases" : [ ],
  "summary" : "Nokogiri: Possible Out-of-Bounds Read in `Nokogiri::XML::NodeSet#[]`",
  "details" : "### Summary\n\n`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.\n\nNokogiri 1.19.4 performs the bounds check against the full-width index.\n\n### Severity\n\nThe Nokogiri maintainers have evaluated this as medium severity.\n\nExploitation 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.\n\nOn JRuby, Nokogiri is not affected by this vulnerability.\n\n### Mitigation\n\nUpgrade to Nokogiri 1.19.4 or later.\n\nAs 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.\n\n### Credit\n\nThis issue was responsibly reported by Zheng Yu from depthfirst.com.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "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"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "nokogiri"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.19.4"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-5prr-v3j2-97mh"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/sparklemotion/nokogiri"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-125", "CWE-190" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-06-19T16:36:42Z",
    "nvd_published_at" : null
  }
}