VYPR
researchPublished Dec 2, 2026· 1 source

HTML Sanitizers Under Fire: Researchers Uncover Widespread Vulnerabilities

A new report details how flaws in fifteen popular HTML sanitizers can be exploited through DOM manipulation and HTML entity overflows, potentially leading to cross-site scripting attacks.

Researchers have identified significant vulnerabilities in fifteen widely-used HTML sanitization libraries, exposing a critical gap in web application security. The discovered flaws leverage sophisticated DOM manipulation techniques and HTML entity overflow exploits, allowing attackers to bypass sanitization mechanisms and inject malicious scripts.

The vulnerabilities fall into several categories, including "DOM clobbering," where elements with specific attributes overwrite native JavaScript functions, and "label jacking," which abuses the for attribute on label elements to trigger actions on host page elements. Libraries like Symfony/html-sanitizer, nahsra/antisamy, and flavorjones/loofah were found to be susceptible to DOM clobbering, while mganss/HtmlSanitizer was vulnerable to label jacking.

Another class of vulnerabilities involves "entity overflows." By submitting excessively large HTML entity values, attackers can cause sanitizers to misinterpret the input, leading to a discrepancy between what the sanitizer processes and what the browser renders. This can be used to bypass security filters, including Web Application Firewalls (WAFs). OWASP/java-html-sanitizer, nahsra/antisamy, and mganss/HtmlSanitizer were affected by these issues.

Specifically, the nahsra/antisamy library was found to be particularly fragile, susceptible to crashing with a single malformed entity and exhibiting issues with how it handles self-closing textarea tags, which browsers interpret differently than the XML-style tags generated by the sanitizer.

The research highlights that even robust sanitizers, like DOMPurify, are not immune to novel attack vectors. The report details a mutation XSS attack that exploits a new HTML feature, demonstrating the ongoing cat-and-mouse game between security researchers and library developers.

These findings underscore the critical importance of thoroughly testing and updating HTML sanitization libraries. The potential impact ranges from minor page disruptions to full-blown cross-site scripting (XSS) attacks, depending on the context in which the sanitized HTML is rendered.

Developers relying on these libraries are urged to review the specific vulnerabilities and update to the latest versions or apply available patches. The research provides detailed technical explanations and proof-of-concept examples, enabling developers to better understand and mitigate these risks within their applications.

Synthesized by Vypr AI