HtmlSanitizer vulnerable to Cross-site Scripting in Foreign Content
Moderate severity
GitHub Reviewed
Published
Oct 4, 2023
in
mganss/HtmlSanitizer
•
Updated Nov 9, 2023
Package
Affected versions
< 8.0.723
>= 8.1.0-beta, < 8.1.722-beta
Patched versions
8.0.723
8.1.722-beta
Description
Published to the GitHub Advisory Database
Oct 4, 2023
Reviewed
Oct 4, 2023
Published by the National Vulnerability Database
Oct 5, 2023
Last updated
Nov 9, 2023
Impact
The vulnerability occurs in configurations where foreign content is allowed, i.e. either
svg
ormath
are in the list of allowed elements.Specifically, the requirements for the vulnerability are:
svg
, ormath
iframe
,noembed
,xmp
,title
,noframes
,style
ornoscript
Configurations that meet the above requirements plus the following are vulnerable to an additional vulnerability:
title
,desc
,mi
,mo
,mn
,ms
,mtext
,annotation-xml
.In case an application sanitizes user input with a vulnerable configuration, an attacker could
bypass the sanitization and inject arbitrary HTML, including JavaScript code.
Note that in the default configuration the vulnerability is not present.
Patches
The vulnerability has been fixed in versions 8.0.723 and 8.1.722-beta (preview version).
Workarounds
Disallow foreign elements
svg
andmath
. This is the case in the default configuration, which is therefore not affected by the vulnerability.References