Miggo Logo

CVE-2022-24836: Nokogiri Inefficient Regular Expression Complexity

7.5

CVSS Score
3.1

Basic Information

EPSS Score
0.76617%
Published
4/11/2022
Updated
7/6/2023
KEV Status
No
Technology
TechnologyRuby

Technical Details

CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Package NameEcosystemVulnerable VersionsFirst Patched Version
nokogirirubygems< 1.13.41.13.4

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The GitHub commit diff shows a critical regex modification in Nokogiri::HTML4::Document.detect_encoding where the pattern was changed from /\A(<?xml[ \t\r\n]+[^>]>)/ to /\A(<?xml[ \t\r\n][^>]>)/ by removing the '+' quantifier. This quantifier caused exponential backtracking when processing inputs with many whitespace characters before the closing '>', leading to ReDoS. The vulnerability description explicitly references this encoding detection regex as the source of inefficiency, and the added test in the commit verifies the performance fix.

Vulnerable functions

Only Mi**o us*rs **n s** t*is s**tion

WAF Protection Rules

WAF Rule

## Summ*ry Noko*iri `< v*.**.*` *ont*ins *n in***i*i*nt r**ul*r *xpr*ssion t**t is sus**pti*l* to *x**ssiv* ***ktr**kin* w**n *tt*mptin* to **t**t *n*o*in* in *TML *o*um*nts. ## Miti**tion Up*r*** to Noko*iri `>= *.**.*`. ## S*v*rity T** Noko*i

Reasoning

T** *it*u* *ommit *i** s*ows * *riti**l r***x mo*i*i**tion in Noko*iri::*TML*::*o*um*nt.**t**t_*n*o*in* w**r* t** p*tt*rn w*s ***n*** *rom /\*(<\?xml[ \t\r\n]+[^>]*>)/ to /\*(<\?xml[ \t\r\n][^>]*>)/ *y r*movin* t** '+' qu*nti*i*r. T*is qu*nti*i*r **u