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.4Details
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></textarea><svg/onload=prompt`xs`></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
- Advisorynvd.nist.gov/vuln/detail/CVE-2017-16016
- Linkgithub.com/punkave/sanitize-html/issues/100
- Linkgithub.com/punkave/sanitize-html/commit/5d205a1005ba0df80e21d8c64a15bb3accdb2403
- Linkgithub.com/punkave/sanitize-html/commit/5d205a1005ba0df80e21d8c64a15bb3accdb2403)))
- Advisorygithub.com/advisories/GHSA-xc6g-ggrc-qq4r
- Linknpmjs.com/package/sanitize-html#discarding-the-entire-contents-of-a-disallowed-tag
- Linkwww.npmjs.com/advisories/154
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.