Miggo Logo

CVE-2018-25061: rgb2hex vulnerable to inefficient regular expression complexity

7.5

CVSS Score
3.1

Basic Information

EPSS Score
0.12588%
Published
12/31/2022
Updated
10/20/2023
KEV Status
No
Technology
TechnologyJavaScript

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
rgb2hexnpm< 0.1.60.1.6

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability stems from inefficient regex patterns in the color parsing logic. The pre-patch regex used \d+ (unbounded digits) and optional groups with overlapping match possibilities, creating exponential time complexity for certain inputs. The commit 9e0c385 explicitly addresses this by: 1) Adding (.*?) to prevent greedy matching attacks, 2) Limiting RGB components to \d{1,3}, 3) Constraining alpha values to [01]??.([0-9]{0,3}), and 4) Adjusting capture group indices. Both index.js and rgb2hex.js contained identical vulnerable regex patterns prior to patching, making their rgb2hex functions the attack surface.

Vulnerable functions

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

WAF Protection Rules

WAF Rule

* vuln*r**ility w*s *oun* in r*****x up to *.*.*. It **s ***n r*t** *s pro*l*m*ti*. T*is issu* *****ts som* unknown pro**ssin*. T** m*nipul*tion l***s to in***i*i*nt r**ul*r *xpr*ssion *ompl*xity. T** *tt**k m*y ** initi*t** r*mot*ly. Up*r**in* to v*

Reasoning

T** vuln*r**ility st*ms *rom in***i*i*nt r***x p*tt*rns in t** *olor p*rsin* lo*i*. T** pr*-p*t** r***x us** \*+ (un*oun*** *i*its) *n* option*l *roups wit* ov*rl*ppin* m*t** possi*iliti*s, *r**tin* *xpon*nti*l tim* *ompl*xity *or **rt*in inputs. T**