Exploited now
Vulnerability WatchVulnerabilities, exploits & advisories — updated every 15 minutes
Alerts

Home › News

News Analysis

PortSwigger Research Details Bypasses in Fifteen Widely Used HTML Sanitizers

According to PortSwigger Research, a researcher tested fifteen widely used HTML sanitizers and demonstrated ways to get past their protections. The report warns that sanitizers alone may not stop cross-site scripting and other injection attacks.

Key points

  • PortSwigger Research reports bypasses in fifteen widely used HTML sanitizers, including symfony/html-sanitizer, rehype-sanitize, and OWASP/java-html-sanitizer.
  • Techniques include DOM clobbering, label manipulation, Unicode entity handling flaws, and serialization and parser differences in AntiSamy and Loofah.
  • Some browser-specific CSS and contenteditable techniques could read and send data from trusted pages in Firefox and Safari beta.
  • The researcher warns that sanitizers should not be the only defense against XSS and injection attacks.

What was tested

According to PortSwigger Research, a security researcher demonstrated vulnerabilities in fifteen widely used HTML sanitizers. Libraries named in the report include symfony/html-sanitizer, rehype-sanitize, and OWASP/java-html-sanitizer. The report also says loofah and mganss/htmlsanitizer were affected, and it describes several separate problems in AntiSamy.

Techniques described

The researcher described several classes of weakness. In one, DOM clobbering let elements with particular names override native DOM functions, and a single element with an id could cause the parser to generate a second element with the same id. Labels could also be manipulated to point at elements outside the sanitized content, which the report says could let untrusted HTML trigger actions in the host application.

Other issues involved how sanitizers handled very large Unicode entity values, which could produce a mismatch between the sanitizer's reading and the browser's. The report says AntiSamy could crash on such an entity, and that it also mis-serialized a textarea and failed to close a comment correctly. In Loofah, certain characters reportedly caused content to be parsed as HTML rather than foreign content. A character described as Safari-specific was also reported to bypass sanitization in a similar way.

The report also covers browser-specific CSS and contenteditable techniques in Firefox and a Safari beta, which it says could be used to read and send data from a trusted page. Some attacks reportedly require particular configurations.

Why it matters

The researcher argues that relying solely on an HTML sanitizer to prevent cross-site scripting and similar injection attacks is risky, and that well-maintained libraries can still have significant gaps if they are misconfigured or not kept up to date. The report states that the issues were not classified as having a confirmed exploit, but proof-of-concept attacks were demonstrated.

The original report includes reproduction details and a token-exfiltration tool, which this summary does not repeat. No fixed versions or CVE identifiers are given in the source material. Readers should consult the original PortSwigger Research report for full technical details.

What to do

  1. Review how your applications use HTML sanitizers, including their configuration, and test the sanitization logic.
  2. Keep sanitizer libraries updated, and do not rely on sanitization alone to prevent cross-site scripting.
  3. Read the original PortSwigger Research report to check which libraries and configurations it describes as affected.

Our article, written with AI assistance from the facts of the original report and the official vulnerability data below. Read the original for full details.

Original report

PortSwigger Researchportswigger.net

“HyperText Mischief Language”

Hacking HTML sanitizers In this post, I'll show you how I attacked fifteen popular HTML sanitizers. We'll start by clobbering native DOM functions, then overflow HTML entities until a sanitizer falls