MediumGHSA-xc6g-ggrc-qq4rCVE-2017-16016

Cross-Site Scripting in sanitize-html

Published 9 Nov 2018 · Updated 8 Nov 2023

Affected package

Affected
<1.11.4
Fixed in
1.11.4
Update to the fixed version for your release line, for example:npm install sanitize-html@1.11.4

Details

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.

Is GHSA-xc6g-ggrc-qq4r in any of your client repos?

Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected sanitize-html, and gives you the command that fixes it.

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.