Loofah: SVG `href` attribute bypasses local-reference restriction
Loofah's HTML5 sanitizer did not restrict the SVG plain href attribute on certain elements, allowing references to arbitrary external documents. This bypasses the intended local-reference restriction applied only to the deprecated xlink:href attribute. The vulnerability affects applications sanitizing user-supplied SVG with Loofah versions prior to 2.25.2. Exploitation could lead to loading and rendering external SVG content with potential script execution in the context of the sanitized document or tracking via external images. Modern browsers limit cross-origin fetches, reducing but not eliminating risk. Upgrading to Loofah 2.25.2 or later mitigates this issue.
AI Analysis
Technical Summary
Loofah's HTML5 sanitizer restricted only the xlink:href attribute on certain SVG elements to local same-document references. However, browsers accept the plain href attribute as an alternative per the SVG 2 specification, but Loofah did not apply the same restriction to href. This allows SVG elements such as <use> to reference arbitrary external documents. If the external SVG is same-origin and contains scripts or dangerous content, it could execute in the sanitized document's context. The <feImage> element can load external images, which can be used for tracking. Modern browsers restrict cross-origin <use> fetches, limiting but not eliminating the risk. Applications using Loofah's default allowlist to sanitize user-supplied SVG are affected. The issue is fixed in Loofah version 2.25.2.
Potential Impact
The vulnerability allows SVG elements to load and render external SVG content or images by referencing arbitrary external documents via the href attribute. This can lead to script execution within the sanitized document's context if the external SVG is same-origin and malicious. Additionally, external images loaded via <feImage> can be used for tracking users. Although modern browsers restrict cross-origin fetches for <use>, the risk remains for same-origin references. This impacts applications that sanitize user-supplied SVG using Loofah versions prior to 2.25.2.
Mitigation Recommendations
Upgrade Loofah to version 2.25.2 or later, where this vulnerability is fixed. No other mitigation is required as the fix addresses the root cause by applying the local-reference restriction to the href attribute on SVG elements.
Loofah: SVG `href` attribute bypasses local-reference restriction
Description
Loofah's HTML5 sanitizer did not restrict the SVG plain href attribute on certain elements, allowing references to arbitrary external documents. This bypasses the intended local-reference restriction applied only to the deprecated xlink:href attribute. The vulnerability affects applications sanitizing user-supplied SVG with Loofah versions prior to 2.25.2. Exploitation could lead to loading and rendering external SVG content with potential script execution in the context of the sanitized document or tracking via external images. Modern browsers limit cross-origin fetches, reducing but not eliminating risk. Upgrading to Loofah 2.25.2 or later mitigates this issue.
CVSS v3.1
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
Weaknesses
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
Loofah's HTML5 sanitizer restricted only the xlink:href attribute on certain SVG elements to local same-document references. However, browsers accept the plain href attribute as an alternative per the SVG 2 specification, but Loofah did not apply the same restriction to href. This allows SVG elements such as <use> to reference arbitrary external documents. If the external SVG is same-origin and contains scripts or dangerous content, it could execute in the sanitized document's context. The <feImage> element can load external images, which can be used for tracking. Modern browsers restrict cross-origin <use> fetches, limiting but not eliminating the risk. Applications using Loofah's default allowlist to sanitize user-supplied SVG are affected. The issue is fixed in Loofah version 2.25.2.
Potential Impact
The vulnerability allows SVG elements to load and render external SVG content or images by referencing arbitrary external documents via the href attribute. This can lead to script execution within the sanitized document's context if the external SVG is same-origin and malicious. Additionally, external images loaded via <feImage> can be used for tracking users. Although modern browsers restrict cross-origin fetches for <use>, the risk remains for same-origin references. This impacts applications that sanitize user-supplied SVG using Loofah versions prior to 2.25.2.
Mitigation Recommendations
Upgrade Loofah to version 2.25.2 or later, where this vulnerability is fixed. No other mitigation is required as the fix addresses the root cause by applying the local-reference restriction to the href attribute on SVG elements.
Technical Details
- Gcve Source
- db.gcve.eu
- Osv Id
- GHSA-9wjq-cp2p-hrgf
- Osv Schema Version
- 1.4.0
- Aliases
- []
- Ecosystems
- ["RubyGems"]
- Database Specific Severity
- MODERATE
- Cvss Version
- 3.1
Threat ID: 6a600aa09c2644c7f8fdfa85
Added to database: 07/22/2026, 00:11:12 UTC
Last enriched: 07/22/2026, 00:37:56 UTC
Last updated: 07/22/2026, 00:37:56 UTC
Views: 2
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.