Nokogiri CSS selector tokenizer has regular expression backtracking
Published: May 06, 2026
SECURITY IDENTIFIERS
- CVE: CVE-2026-79770 (NVD)
- GHSA: GHSA-c4rq-3m3g-8wgx
- Vendor Advisory: https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-c4rq-3m3g-8wgx
GEM
SEVERITY
CVSS v3.x: 7.5 (High)
PATCHED VERSIONS
>= 1.19.3
DESCRIPTION
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.
Credit
Vector 1 was responsibly reported by @colby-swandale. Vectors 2 and 3 were discovered by @flavorjones during the response to the original report.
RELATED
- https://nvd.nist.gov/vuln/detail/CVE-2026-79770
- https://rubygems.org/gems/nokogiri/versions/1.19.3
- https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md#v1193--2026-04-27
- https://www.vulncheck.com/advisories/nokogiri-before-redos-via-css-selector-tokenizer
- https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-c4rq-3m3g-8wgx
- https://github.com/advisories/GHSA-c4rq-3m3g-8wgx
