Loofah: SVG `href` attribute bypasses local-reference restriction
Moderate severity
GitHub Reviewed
Published
Jul 15, 2026
in
flavorjones/loofah
•
Updated Jul 21, 2026
Description
Published to the GitHub Advisory Database
Jul 21, 2026
Reviewed
Jul 21, 2026
Last updated
Jul 21, 2026
Summary
Loofah's HTML5 sanitizer restricted only the
xlink:hrefattribute on certain SVG elements to local, same-document references. Browsers also accept a plainhrefattribute as an alternative to the deprecatedxlink:hrefper the SVG 2 spec, but Loofah did not apply the same restriction to it, allowing those elements to reference arbitrary external documents.Impact
SVG
<use>can load and render external SVG content by reference. If the referenced external SVG is same-origin and contains scripts or other dangerous content, it could execute in the context of the sanitized document.<feImage>can load external images, which can be used for tracking. Modern browsers restrict cross-origin<use>fetches, which limits but does not eliminate the risk.Applications that sanitize user-supplied SVG (directly, or as part of HTML) with Loofah's default allowlist are affected.
Mitigation
Upgrade to Loofah >= 2.25.2.
Credit
Found by the maintainer, Mike Dalessio, during a security audit.
References