Miggo Logo

CVE-2021-32817:
Insecure template handling in express-hbs

5.4

CVSS Score
3.1

Basic Information

EPSS Score
0.6403%
Published
5/17/2021
Updated
4/4/2023
KEV Status
No
Technology
TechnologyJavaScript

Technical Details

CVSS Vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:L/I:L/A:N
Package NameEcosystemVulnerable VersionsFirst Patched Version
express-hbsnpm<= 2.4.0

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability stems from express-hbs's handling of the 'layout' parameter in the Express render API. When applications pass user-controlled data (e.g., req.query) to res.render, attackers can inject a 'layout' value pointing to arbitrary files. The engine resolves this parameter to read files from disk (with existing extensions) or appends .hbs to extensionless paths. The commit diff and advisory explicitly warn about this pattern, and the CWE-200/CWE-94 mappings confirm improper input validation and information exposure. While the exact internal function name isn't visible in provided data, the core issue manifests in the layout handling logic during rendering.

Vulnerable functions

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

WAF Protection Rules

WAF Rule

*xpr*ss-**s is *n *xpr*ss **n*l***rs t*mpl*t* *n*in*. *xpr*ss-**s mix*s pur* t*mpl*t* **t* wit* *n*in* *on*i*ur*tion options t*rou** t** *xpr*ss r*n**r *PI. Mor* sp**i*i**lly, t** l*yout p*r*m*t*r m*y tri***r *il* *is*losur* vuln*r**iliti*s in *ownst

Reasoning

T** vuln*r**ility st*ms *rom *xpr*ss-**s's **n*lin* o* t** 'l*yout' p*r*m*t*r in t** *xpr*ss r*n**r *PI. W**n *ppli**tions p*ss us*r-*ontroll** **t* (*.*., `r*q.qu*ry`) to `r*s.r*n**r`, *tt**k*rs **n inj**t * 'l*yout' v*lu* pointin* to *r*itr*ry *il*