CVE-2021-28092: Regular Expression Denial of Service (ReDoS) in is-svg package

is-svg Updated 02 Oct 2025

Summary

19/03/2021
Yes i
High
7.5

CVE-2021-28092: Regular Expression Denial of Service (ReDoS). Affects is-svg versions >= 2.1.0, < 4.2.2. Fixed in 4.2.2. 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 Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

The is-svg package is a Node.js package used for determining whether a given string represents an SVG image. It provides a function called isSvg that takes a string as input and checks if it is a valid SVG image. The package is commonly used in Node.js applications that deal with SVG images.

Vulnerability Detail

The is-svg package versions 2.1.0 through 4.2.1 are vulnerable to Regular Expression Denial of Service (ReDoS) attacks. This vulnerability arises from the use of a regular expression that can be exploited by an attacker to cause the package to hang indefinitely when processing a malicious string. This can lead to a denial of service (DoS) condition, where the application becomes unresponsive and unavailable to legitimate users.

How To Fix

Minimum fixed version

4.2.2

This is the first release that contains the fix.

npm install is-svg@4.2.2

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If upgrading to the latest version of is-svg is not immediately feasible, a possible workaround is to implement input validation and sanitization in the application code. By carefully validating and sanitizing user input before passing it to the isSvg function, the risk of triggering the ReDoS vulnerability can be reduced. Here is an example of how input validation can be implemented in JavaScript:

const isSvg = require('is-svg');

function validateSvg(input) {
  // Perform input validation and sanitization
  if (typeof input !== 'string') {
    throw new Error('Invalid input');
  }

  // Call isSvg function with sanitized input
  return isSvg(input);
}

Conclusion

The is-svg package versions 2.1.0 through 4.2.1 for Node.js are vulnerable to Regular Expression Denial of Service (ReDoS). It is recommended to upgrade to version 4.2.2 or later to fix this vulnerability. If immediate upgrade is not possible, implementing input validation and sanitization can serve as a temporary workaround. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for is-svg →

Share this vulnerability

FAQ

The is-svg package is a Node.js package used for determining whether a given string represents an SVG image. It provides a function called isSvg that takes a string as input and checks if it is a valid SVG image.

Regular Expression Denial of Service (ReDoS) is a type of vulnerability that arises when a regular expression pattern can be exploited by an attacker to cause the application to hang or consume excessive resources when processing certain input strings.

The vulnerability in the is-svg package can be exploited by an attacker to cause a denial of service (DoS) condition. This can lead to the application becoming unresponsive and unavailable to legitimate users.

To fix this vulnerability, it is recommended to upgrade to is-svg version 4.2.2 or later. This version includes a fix for the regular expression that mitigates the ReDoS vulnerability.

If upgrading to the latest version of is-svg is not immediately feasible, a possible workaround is to implement input validation and sanitization in the application code to reduce the risk of triggering the ReDoS vulnerability.

Related vulnerabilities

Recent vulnerabilities recorded for is-svg.

How To Fix

Minimum fixed version

4.2.2

This is the first release that contains the fix.

npm install is-svg@4.2.2

Tip — Not sure which version your app runs? Vulert can match this fix to it. 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