Executive brief
Loofah is a Ruby library for sanitizing and manipulating HTML documents. A flaw in its URI validation allows attackers to bypass protections against malicious JavaScript and VBScript URIs by encoding the scheme separator (colon or whitespace) with numeric character references. An attacker can craft HTML that appears safe to Loofah but executes in browsers, potentially leading to cross-site scripting (XSS) attacks on websites using the library.
Technical details
The vulnerability exists in Loofah::HTML5::Scrub.allowed_uri? (versions 2.25.0–2.25.1), which fails to properly decode semicolon-less numeric character references (e.g., :, 	, 
, 
) before validating URI schemes. While CGI.unescapeHTML decodes only references with trailing semicolons, browsers decode these malformed references and reconstruct dangerous schemes like javascript: or vbscript:. The flaw only affects callers passing HTML-encoded strings directly to allowed_uri?; the default sanitize() path is unaffected. An attacker must provide HTML input to trigger allowed_uri? validation. The issue was fixed in version 2.25.2 by decoding semicolon-less numeric references before scheme validation.
Affected products
- Loofah Loofah 2.25.0 to 2.25.1
Timeline
- 2026-08-12: disclosed
- 2026-07-15: patched: Fix committed and released in version 2.25.2