Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2026-107380 Overview
CVE-2026-107380 is a Cross-Site Scripting (XSS) vulnerability [CWE-79] in svg-sanitizer, a PHP library used to sanitize SVG and XML content before embedding it in HTML pages. The flaw affects all versions prior to 1.0.0. The sanitizer's isHrefSafeValue() function validates SVG href attributes after XML Document Type Definition (DTD) entity expansion. However, saveXML() serializes the original entity reference after stripping the DTD. An attacker can craft an SVG with entities that look safe to the sanitizer but resolve to a javascript: URL once the browser performs HTML5 Named Character Reference resolution during inline rendering.
Critical Impact
A user who clicks a crafted link inside an embedded SVG triggers JavaScript execution in the embedding page's origin, enabling session theft, defacement, or further client-side attacks.
Affected Products
- darylldoyle/svg-sanitizer versions prior to 1.0.0
- PHP applications that embed sanitized SVG markup inline in HTML
- Content management systems and web applications depending on the library for SVG upload sanitization
Discovery Timeline
- 2026-10-08 - CVE-2026-107380 published to NVD
- 2026-10-09 - Last updated in NVD database
Technical Details for CVE-2026-107380
Vulnerability Analysis
The vulnerability stems from a parsing discrepancy between the sanitizer's validation stage and the browser's HTML rendering stage. svg-sanitizer loads the SVG with its DTD intact, allowing XML entity expansion before isHrefSafeValue() inspects the resolved href value. The check sees a benign prefix and permits the attribute.
When the library then calls saveXML(), the DTD declaration is removed but the entity reference remains in the serialized output. The browser later encounters that surviving reference during inline SVG rendering and applies HTML5 Named Character Reference resolution. The reference resolves to whitespace characters such as a tab, which the browser strips when parsing URL schemes. The result is a javascript: URL that the sanitizer never saw.
Exploitation requires a victim to activate the link, so the attack is user-interaction dependent. Once activated, the script runs in the origin of the hosting page.
Root Cause
The root cause is inconsistent entity handling between validation and serialization. The sanitizer validates post-expansion content but emits pre-expansion markup, breaking the equivalence that a sanitizer must maintain between what it inspects and what it outputs.
Attack Vector
An authenticated attacker uploads or submits a crafted SVG file to an application that uses svg-sanitizer to clean user-supplied SVG content. The SVG contains an <a> element whose href attribute uses an XML entity reference. After sanitization and inline embedding, a victim who clicks the link executes attacker-controlled JavaScript in the application's origin. Refer to the GitHub Security Advisory GHSA-9rjx-3jch-6vjf for the full technical write-up.
Detection Methods for CVE-2026-107380
Indicators of Compromise
- SVG uploads containing XML <!ENTITY> declarations or &entity; references inside href, xlink:href, or other URL-bearing attributes
- Rendered pages where anchor targets inside SVG resolve to javascript: schemes after whitespace normalization
- Unexpected outbound requests or DOM modifications originating from SVG-embedded links
Detection Strategies
- Scan user-uploaded SVG files for DTD declarations and entity references before and after sanitization, and compare the two representations
- Inspect served HTML for anchor elements whose href begins with whitespace or control characters followed by javascript:
- Audit dependency manifests (composer.lock) for enshrined/svg-sanitize or darylldoyle/svg-sanitizer at versions below 1.0.0
Monitoring Recommendations
- Log and alert on Content Security Policy (CSP) violations involving inline script execution on pages that render user SVG content
- Monitor web server logs for SVG uploads containing the strings <!DOCTYPE, <!ENTITY, or within attribute contexts
- Track client-side errors and anomalous window.location changes on pages that embed sanitized SVG
How to Mitigate CVE-2026-107380
Immediate Actions Required
- Upgrade darylldoyle/svg-sanitizer to version 1.0.0 or later via Composer
- Audit existing stored SVG content for entity references and re-sanitize or remove suspect files
- Enforce a strict Content Security Policy that blocks inline script execution and javascript: URL navigation
Patch Information
The maintainer fixed the issue in version 1.0.0. The corrective commit updates entity handling so the serialized output matches the validated content. See the patch commit 23877db and the 1.0.0 release notes.
Workarounds
- Serve user-supplied SVG from a sandboxed origin or as a downloaded resource rather than inline markup
- Strip or reject any SVG containing a DTD or entity reference before passing it to the sanitizer
- Apply a response-level CSP header such as Content-Security-Policy: default-src 'self'; script-src 'self' to limit script execution if sanitization is bypassed
# Upgrade svg-sanitizer to the patched release
composer require enshrined/svg-sanitize:^1.0.0
composer update enshrined/svg-sanitize
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

