CVE-2023-24540:
Not all valid JavaScript whitespace characters are considered to be whitespace. Templates...
9.8
Basic Information
Technical Details
Vulnerability Intelligence
Miggo AI
Root 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.