SVGO Vulnerability: Incomplete Script Removal Leading to Potential XSS Attacks

svgo Updated 21 Jul 2026

Summary

21/07/2026
HIGH
Yes i
High
8.2

GHSA-2p49-hgcm-8545: SVGO removeScripts plugin leaves some executable scripts intact. Affects svgo across 3 version ranges.

>= 1.0.0, < 2.8.3 >= 3.0.0, < 3.3.4 >= 4.0.0, < 4.0.2

Fixed in 2.8.3, 3.3.4 or 4.0.2, depending on the release line you run. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

SVGO (SVG Optimizer) is a Node.js-based tool used to optimize SVG files by removing unnecessary data, thereby reducing file size and improving performance. It includes various plugins, one of which is the removeScripts plugin, designed to eliminate executable scripts from SVG files. However, this plugin has a flaw that allows certain scripts to remain intact, posing a security risk.

Vulnerability Detail

The vulnerability arises from the removeScripts plugin of SVGO, which is intended to sanitize SVG files by removing script elements. However, it fails to remove namespaced or prefixed script elements, such as svg:script, and does not handle case sensitivity for JavaScript URIs. This oversight can lead to Cross-Site Scripting (XSS) attacks if an attacker embeds malicious scripts within SVG files that are processed by SVGO and served to users. The vulnerability is particularly concerning for applications that rely on SVGO for sanitization of user-uploaded SVGs.

How To Fix

Latest published version: 4.1.0 as of 23 Oct 2026

npm install svgo@4.1.0

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • >= 1.0.0, < 2.8.3 2.8.3
    npm install svgo@2.8.3
  • >= 3.0.0, < 3.3.4 3.3.4
    npm install svgo@3.3.4
  • >= 4.0.0, < 4.0.2 4.0.2
    npm install svgo@4.0.2

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

If you need to sanitize SVGs and cannot upgrade SVGO, consider using a dedicated SVG sanitization tool before passing the SVG to SVGO. This will help ensure that all executable scripts are removed before optimization.

Conclusion

The SVGO vulnerability related to the removeScripts plugin poses a significant risk of XSS attacks due to its failure to remove certain script elements from SVG files. Users are strongly advised to update to the latest patched versions of SVGO or implement alternative sanitization methods to mitigate this risk.

See every vulnerability recorded for svgo →

Share this vulnerability

FAQ

The CVSS score of this vulnerability is 8.2, indicating a high severity level.

You can use Vulert, which monitors and alerts for open-source vulnerabilities in real-time. You can check your application using the Vulert playground at Vulert Scanner without any signup.

SVGO versions 1.0.0 to 1.3.2, 2.0.0 to 2.8.2, 3.0.0 to 3.3.4, and 4.0.0 to 4.0.1 are affected by this vulnerability.

If upgrading is not an option, consider using a dedicated SVG sanitization tool to remove scripts before processing with SVGO.

If exploited, this vulnerability could allow attackers to execute scripts in the context of a user's browser, potentially accessing sensitive information like cookies or local storage.

Related vulnerabilities

Recent vulnerabilities recorded for svgo.

How To Fix

Latest published version: 4.1.0 as of 23 Oct 2026

npm install svgo@4.1.0

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • >= 1.0.0, < 2.8.3 2.8.3
    npm install svgo@2.8.3
  • >= 3.0.0, < 3.3.4 3.3.4
    npm install svgo@3.3.4
  • >= 4.0.0, < 4.0.2 4.0.2
    npm install svgo@4.0.2

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback