SVGO: removeScripts incompletely sanitizes executable HTML in SVG foreignObject elements
Summary
SVGO's opt-in removeScripts plugin did not inspect executable HTML content inside SVG <foreignObject> elements. Applications that used this plugin as their only protection for untrusted SVG input could produce SVGs containing active HTML and expose users to cross-site scripting (XSS).
SVGO is an optimizer rather than a comprehensive sanitization library, but removeScripts is maintained for consumers that already rely on it to remove common script execution paths.
Details
Although the plugin removed SVG and XHTML <script> elements, it left other HTML execution paths inside <foreignObject> unchanged. These included:
- event-handler attributes such as
onloadandonbeforetoggle; srcdocdocuments, including on<iframe>elements;- executable URLs in HTML attributes such as
action,data,formaction,href, andsrc.
An attacker could place one of these payloads in an SVG. If an application optimized the untrusted SVG with removeScripts and then served the result in an active browser context, the payload could execute in the viewer's origin.
Impact
Successful exploitation could allow script execution in the context where the optimized SVG is rendered. Depending on the embedding and origin configuration, this could expose cookies or local storage, modify content, or perform actions as the victim.
The plugin is opt-in, so consumers that do not enable removeScripts are not relying on the affected behavior. Typical local optimization of trusted SVG files is not affected.
Patches
Upgrade to one of the following releases for the maintained release line in use:
| Release line | Patched version | Plugin |
|---|---|---|
| v2 | 2.8.4 | removeScriptElement |
| v3 | 3.3.5 | removeScriptElement |
| v4 | 4.1.0 | removeScripts |
The fix preserves visual HTML inside SVG <foreignObject> elements while removing event attributes, srcdoc, and executable URL values from active HTML URL attributes.
SVGO v1 is no longer maintained. Users of v1 should upgrade to a supported release line.
Workarounds
For hostile input, use a dedicated SVG sanitization tool before passing the SVG to SVGO. As defense in depth, applications can reject or remove <foreignObject> content and avoid serving user-controlled SVGs in an active same-origin context.
Affected software
Click a technology to see all vulnerabilities affecting it.
| Platform | Package | Vulnerable versions | Fixed in |
|---|---|---|---|
| npm package | svgo | >= 1.0.0, < 2.8.4, >= 3.0.0, < 3.3.5, >= 4.0.0, < 4.1.0 | 2.8.4, 3.3.5, 4.1.0 |
References
- https://github.com/svg/svgo/security/advisories/GHSA-4vpr-x523-8j87
- https://nvd.nist.gov/vuln/detail/CVE-2026-84369
- https://github.com/svg/svgo/pull/2264
- https://github.com/svg/svgo/pull/2269
- https://github.com/svg/svgo/pull/2272
- https://github.com/svg/svgo/commit/0557385564a5c6c11d76cd934a6cff94451e532c
- https://github.com/svg/svgo/commit/994a9f00d79ddec68ce19a1ce9eb8ca08d747e4f
- https://github.com/svg/svgo/commit/fd51e474a300417d9361d9302d596b1763146327
- https://github.com/svg/svgo
- https://github.com/svg/svgo/releases/tag/v2.8.4
- https://github.com/svg/svgo/releases/tag/v3.3.5
- https://github.com/svg/svgo/releases/tag/v4.1.0
- CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N- Weakness (CWE)
CWE-79- Platform
- npm
- Package
svgo- Disclosed
- 08.09.2026
- Updated
- 11.10.2026 10:22
Sources and licenses
OSV / GitHub Advisory Database - GHSA-4vpr-x523-8j87 - CC BY 4.0
Vulnerability history: svgo
All published vulnerabilities of this package (npm package), newest first. Shows whether this is a one-off slip or a package that needs watching.
- Total entries
- 4
- First → latest
- 03.2026 09.2026
- Without a fix
- 0
- Exploited in attacks
- 0
Severity breakdown
- High 3
- Medium 1
Disclosures per year
- 2026: 4
-
SVGO: removeScripts incompletely sanitizes executable HTML in SVG foreignObject elements this entry
Know which vulnerabilities affect your application
With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.