Miggo Logo

CVE-2021-21321: Prefix escape

10

CVSS Score
3.1

Basic Information

EPSS Score
0.6278%
Published
3/3/2021
Updated
2/1/2023
KEV Status
No
Technology
TechnologyJavaScript

Technical Details

CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N
Package NameEcosystemVulnerable VersionsFirst Patched Version
fastify-reply-fromnpm< 4.0.24.0.2

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability stems from improper path validation in URL construction. The commit dea227d shows the fix was applied to the buildURL function in lib/utils.js, where they added logic to: 1) Ensure base URLs get trailing slashes, and 2) Validate the full destination URL starts with the normalized base. The pre-patch code only checked origin matching (reqBase.startsWith(dest.origin)), which failed to prevent path escapes when base URLs lacked trailing slashes. The added test cases in test/build-url.js demonstrate scenarios where crafted URLs could bypass the prefix restriction before the fix.

Vulnerable functions

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

WAF Protection Rules

WAF Rule

### Imp**t *y *r**tin* * sp**i*i* URL, it is possi*l* to *s**p* t** pr**ix o* t** proxi** ***k*n* s*rvi**. I* t** **s* url o* t** proxi** s*rv*r is `/pu*/`, * us*r *xp**t t**t ****ssin* `/priv` on t** t*r**t s*rvi** woul* not ** possi*l*. Un*ortun*t

Reasoning

T** vuln*r**ility st*ms *rom improp*r p*t* v*li**tion in URL *onstru*tion. T** *ommit ******* s*ows t** *ix w*s *ppli** to t** `*uil*URL` *un*tion in `li*/utils.js`, w**r* t**y ***** lo*i* to: *) *nsur* **s* URLs **t tr*ilin* sl*s**s, *n* *) V*li**t*