Miggo Logo

CVE-2023-24540:
Not all valid JavaScript whitespace characters are considered to be whitespace. Templates...

9.8

CVSS Score
3.1

Basic Information

EPSS Score
0.47592%
Published
5/11/2023
Updated
1/24/2025
KEV Status
No
Technology
-

Technical Details

CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability CVE-2023-24540 in Go's html/template package was due to an incomplete definition of JavaScript whitespace characters. The core flawed logic resided in the internal isJSWhitespace function. This function was used by other internal sanitization functions, specifically jsStrNorm (for JS strings) and jsRegexpNorm (for JS regular expressions), to correctly process and sanitize content within JavaScript contexts in templates. The public API functions Template.Execute and Template.ExecuteTemplate are the entry points for rendering templates and thus invoke this sanitization logic. When these functions processed templates containing JavaScript actions and specific Unicode whitespace characters not recognized by the old isJSWhitespace implementation, the sanitization could be bypassed, leading to potential XSS. The patch commit 296324340ad9e0999f7882702996130aa374510c directly fixed isJSWhitespace by expanding its definition of whitespace using unicode.IsSpace and adjusting the explicit character checks. The Go advisory GO-2023-1752 confirmed Template.Execute and Template.ExecuteTemplate as the affected symbols, highlighting that the vulnerability impacts these user-facing functions through their reliance on the flawed internal sanitization.

Vulnerable functions

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

WAF Protection Rules

WAF Rule

Not *ll v*li* J*v*S*ript w*it*sp*** ***r**t*rs *r* *onsi**r** to ** w*it*sp***. T*mpl*t*s *ont*inin* w*it*sp*** ***r**t*rs outsi** o* t** ***r**t*r s*t "\t\n\*\r\u****\u****\u****" in J*v*S*ript *ont*xts t**t *lso *ont*in **tions m*y not ** prop*rly

Reasoning

T** vuln*r**ility *V*-****-***** in *o's `*tml/t*mpl*t*` p**k*** w*s *u* to *n in*ompl*t* ***inition o* J*v*S*ript w*it*sp*** ***r**t*rs. T** *or* *l*w** lo*i* r*si*** in t** int*rn*l `isJSW*it*sp***` *un*tion. T*is *un*tion w*s us** *y ot**r int*rn*