Summary
Nokogiri's CSS selector tokenizer contains regular expressions whose construction may result in exponential regex backtracking on adversarial selectors. Three ReDoS vectors are addressed in this release:
- String-literal tokenization on certain unterminated quoted-string input.
- String-literal tokenization on a separate class of hex-escape-rich input.
- Identifier tokenization on hex-escape-rich input.
The public CSS selector methods that funnel through the affected tokenizer are Nokogiri::CSS.xpath_for, Node#css, Node#at_css, Searchable#search, and CSS::Parser#parse.
Mitigation
Upgrade to Nokogiri >= 1.19.3.
If users are unable to upgrade, two options are available:
- Avoid the use of attacker-controlled text in CSS selectors. Applications that only pass developer-authored selectors to Nokogiri are not directly exposed.
- Set global
Regexp.timeout(Ruby 3.2+, JRuby 9.4+) to bound parse time.
Severity
The Nokogiri maintainers have evaluated this as High Severity (CVSS 7.5, AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).
An attacker able to inject user-supplied text into a CSS selector parse method can cause exponential backtracking, resulting in a potential denial of service.
Resources
Credit
Vector 1 was responsibly reported by @colby-swandale. Vectors 2 and 3 were discovered by @flavorjones during the response to the original report.
Impact
A regular expression with worst-case exponential or polynomial matching time is applied to untrusted input, causing excessive CPU use. Typical impact: denial of service when input is crafted to trigger backtracking.
GHSA-C4RQ-3M3G-8WGX has a CVSS score of 7.5 (High). The vector is network-reachable, no privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (1.19.3); upgrading removes the vulnerable code path.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Remediation advice
Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.
Frequently Asked Questions
- What is GHSA-C4RQ-3M3G-8WGX? GHSA-C4RQ-3M3G-8WGX is a high-severity inefficient regular expression (ReDoS) vulnerability in nokogiri (rubygems), affecting versions < 1.19.3. It is fixed in 1.19.3. A regular expression with worst-case exponential or polynomial matching time is applied to untrusted input, causing excessive CPU use.
- How severe is GHSA-C4RQ-3M3G-8WGX? GHSA-C4RQ-3M3G-8WGX has a CVSS score of 7.5 (High). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which versions of nokogiri are affected by GHSA-C4RQ-3M3G-8WGX? nokogiri (rubygems) versions < 1.19.3 is affected.
- Is there a fix for GHSA-C4RQ-3M3G-8WGX? Yes. GHSA-C4RQ-3M3G-8WGX is fixed in 1.19.3. Upgrade to this version or later.
- Is GHSA-C4RQ-3M3G-8WGX exploitable, and should I be worried? Whether GHSA-C4RQ-3M3G-8WGX is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether GHSA-C4RQ-3M3G-8WGX is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix GHSA-C4RQ-3M3G-8WGX? Upgrade
nokogirito 1.19.3 or later.