CVE-2018-25061: rgb2hex vulnerable to inefficient regular expression complexity
7.5
CVSS Score
3.1
Basic Information
CVE ID
GHSA ID
EPSS Score
0.12588%
CWE
Published
12/31/2022
Updated
10/20/2023
KEV Status
No
Technology
JavaScript
Technical Details
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
---|---|---|---|
rgb2hex | npm | < 0.1.6 | 0.1.6 |
Vulnerability Intelligence
Miggo AI
Root 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.