Miggo Logo

CVE-2021-23358: Underscore.js Template Function Arbitrary Code Injection Vulnerability

9.8

CVSS Score
3.1

Basic Information

EPSS Score
0.75684%
Published
5/6/2021
Updated
11/29/2023
KEV Status
No
Technology
TechnologyJavaScript

Technical Details

CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Package NameEcosystemVulnerable VersionsFirst Patched Version
underscorenpm>= 1.3.2, < 1.12.11.12.1

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability stems from the template function's handling of the settings.variable parameter. The commit diff shows the addition of a regex (bareIdentifier) to validate this parameter, which was previously unsanitized. When settings.variable is controlled by an attacker (e.g., via _.templateSettings.variable), it could contain malicious JS code executed during template compilation via new Function(). The CVE description explicitly references the template function as the attack vector, and the patch directly addresses this by adding input validation.

Vulnerable functions

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

WAF Protection Rules

WAF Rule

T** p**k*** `un**rs*or*` *rom *.**.*-* *n* ***or* *.**.*-*, *rom *.*.* *n* ***or* *.**.* *r* vuln*r**l* to *r*itr*ry *o** *x**ution vi* t** t*mpl*t* *un*tion, p*rti*ul*rly w**n * v*ri**l* prop*rty is p*ss** *s *n *r*um*nt *s it is not s*nitiz**.

Reasoning

T** vuln*r**ility st*ms *rom t** `t*mpl*t*` *un*tion's **n*lin* o* t** `s*ttin*s.v*ri**l*` p*r*m*t*r. T** *ommit *i** s*ows t** ***ition o* * r***x (`**r*I**nti*i*r`) to v*li**t* t*is p*r*m*t*r, w*i** w*s pr*viously uns*nitiz**. W**n `s*ttin*s.v*ri**