CVE-2026-79770: Nokogiri before 1.19.3 ReDoS via CSS selector tokenizer
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:
1. String-literal tokenization on certain unterminated quoted-string input. 2. String-literal tokenization on a separate class of hex-escape-rich input. 3. Identifier tokenization on hex-escape-rich input.
The public CSS selector methods that funnel through the affected tokenizer are Nokogiri::CSS.xpathfor, Node#css, Node#atcss, 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
- CWE-1333: Inefficient Regular Expression Complexity
Credit
Vector 1 was responsibly reported by @colby-swandale. Vectors 2 and 3 were discovered by @flavorjones during the response to the original report.
Other sources
Nokogiri versions before 1.19.3 contain regular expression denial of service vulnerabilities in the CSS selector tokenizer affecting string-literal and identifier tokenization. Attackers can inject adversarial CSS selectors into methods like Node#css, Node#atcss, and Searchable#search to cause exponential regex backtracking and denial of service.
— NVD
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
rubygems/nokogirito a version that resolves this vulnerability.Fixed in 1.19.3 - Upgrade
Upgrade
debian/ruby-nokogirito a version that resolves this vulnerability.Fixed in 1.19.3+dfsg-1 - Upgrade
Upgrade
nokogirito a version that resolves this vulnerability.Fixed in 1.19.3 - Configuration
Set the global Regexp.timeout to bound parsing time (Ruby 3.2+ or JRuby 9.4+).
Regexp.timeout - Compensating control
Avoid passing attacker-controlled or user-supplied text to CSS selector parsing methods.
Event History
Frequently Asked Questions
Which applications are realistically exposed to this issue?
Applications using Nokogiri before 1.19.3 are exposed when they pass attacker-controlled CSS selector strings to Node#css, Node#at_css, or Searchable#search. The impact is denial of service through excessive regular-expression backtracking.
Does exploitation require authentication or user interaction?
No. The supplied severity vector indicates network access, low attack complexity, no privileges required, and no user interaction.
What version resolves the vulnerability?
Upgrade Nokogiri to version 1.19.3 or later. The affected versions are those before 1.19.3.