GHSA-cj75-f6xr-r4g7: Cross-Site Scripting (XSS) Bypass via SVG href Attributes in rails-html-sanitizer
Vulnerability ID: GHSA-CJ75-F6XR-R4G7
CVSS Score: 5.1
Published: 2026-07-21
An issue in rails-html-sanitizer allowed attackers to bypass restrictions on SVG reference elements (such as
TL;DR
Custom configurations of rails-html-sanitizer allowing SVG reference tags were vulnerable to XSS and tracking because plain 'href' attributes bypassed local-reference filters restricted only to 'xlink:href'.
⚠️ Exploit Status: POC
Technical Details
- CWE ID: CWE-79
- Attack Vector: Network
- CVSS v4 Score: 5.1 (Medium)
- Exploit Status: poc
- KEV Status: Not Listed
- Component: rails-html-sanitizer
Affected Systems
- Ruby on Rails applications using custom rails-html-sanitizer configurations allowing SVG elements
-
rails-html-sanitizer: >= 1.0.3, < 1.7.1 (Fixed in:
1.7.1)
Code Analysis
Commit: 74dcb80
Fix XSS vulnerability with certain configurations by checking all SVG href attributes
--- a/lib/rails/html/scrubbers.rb
+++ b/lib/rails/html/scrubbers.rb
@@ -172,7 +172,7 @@ def scrub_attribute(node, attr_node)
Loofah::HTML5::Scrub.scrub_attribute_that_allows_local_ref(attr_node)
end
- if Loofah::HTML5::SafeList::SVG_ALLOW_LOCAL_HREF.include?(node.name) && attr_name == "xlink:href" && attr_node.value =~ /^\s*[^#\s].*/m
+ if Loofah::HTML5::SafeList::SVG_ALLOW_LOCAL_HREF.include?(node.name) && Loofah::HTML5::SafeList::SVG_HREF_ATTRIBUTES.include?(attr_name) && attr_node.value =~ /^\s*[^#\s].*/m
attr_node.remove
end
Exploit Details
- rails-html-sanitizer test suite: The test suite includes functional PoCs proving that external plain href tags in
Mitigation Strategies
- Upgrade rails-html-sanitizer to version 1.7.1 or higher.
- Audit custom sanitization lists to ensure
- Deploy a custom scrubber to programmatically block SVG reference elements if immediate upgrade is impossible.
Remediation Steps:
- Modify Gemfile to specify gem 'rails-html-sanitizer', '>= 1.7.1'.
- Run 'bundle update rails-html-sanitizer loofah'.
- Verify that the resolved loofah version is 2.25.2 or higher.
- Inspect application sanitizers for custom tag overrides permitting 'use' or 'feImage'.
References
- GitHub Security Advisory GHSA-cj75-f6xr-r4g7
- Upstream Related Loofah Advisory
- MITRE CWE Reference for Cross-Site Scripting (CWE-79)
Read the full report for GHSA-CJ75-F6XR-R4G7 on our website for more details including interactive diagrams and full exploit analysis.
Top comments (0)