CVE-2021-23631: Path Traversal in convert-svg packages

convert-svg-core Updated 02 Oct 2025

Summary

27/01/2022
No i
High
7.5

CVE-2021-23631: Path Traversal in convert-svg packages. Affects convert-svg-core versions < 0.5.0. No fix is published. 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

The convert-svg package is a collection of npm packages that provide functionality for converting SVG files to other formats such as PNG and JPEG. The affected packages include convert-svg-core, convert-svg-to-png, and convert-svg-to-jpeg. These packages are widely used for converting SVG files in various applications.

Vulnerability Detail

The vulnerability (CVE-2021-23631) allows an attacker to perform path traversal attacks by exploiting a flaw in the convert-svg packages. By providing a specially crafted SVG file, an attacker can read arbitrary files from the file system. The attacker can then display the content of these files as converted PNG files. This can lead to unauthorized access to sensitive information and potential data breaches.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Workaround

If updating the packages is not immediately feasible, a temporary workaround is to implement input validation and sanitization for SVG files. This can help prevent the exploitation of the path traversal vulnerability. Here is an example of how to validate and sanitize SVG file paths in Node.js:

const path = require('path');

function sanitizeSvgPath(filePath) {
  const baseDir = '/path/to/svgs'; // Set the base directory for SVG files
  const resolvedPath = path.resolve(baseDir, filePath);

  if (!resolvedPath.startsWith(baseDir)) {
    throw new Error('Invalid SVG file path');
  }

  return resolvedPath;
}

This code snippet ensures that the resolved file path is within the specified base directory, preventing any attempts to traverse outside of it.

Conclusion

The path traversal vulnerability in the convert-svg packages (convert-svg-core, convert-svg-to-png, and convert-svg-to-jpeg) can allow an attacker to read arbitrary files from the file system. It is crucial to update the packages to the latest patched versions (0.5.1 or higher) to mitigate this vulnerability. Additionally, implementing input validation and sanitization for SVG file paths can provide a temporary workaround until the packages are updated. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for convert-svg-core →

Share this vulnerability

FAQ

The vulnerability allows an attacker to read arbitrary files from the file system and display their content as converted PNG files. This can lead to unauthorized access to sensitive information and potential data breaches.

All versions of convert-svg-core, convert-svg-to-png, and convert-svg-to-jpeg up to and including version 0.5.0 are affected by this vulnerability.

You can use the Vulert Playground (https://vulert.com/scanner) to check if your application is affected by this vulnerability. Simply upload your package-lock.json file to the playground and it will analyze your dependencies for known vulnerabilities.

Yes, a fix is available in the latest versions of the convert-svg packages (0.5.1 or higher). It is recommended to update your package dependencies to ensure you are using the patched versions.

A temporary workaround is to implement input validation and sanitization for SVG file paths. This can help prevent the exploitation of the path traversal vulnerability. Refer to the 'workaround' section for an example implementation.

Related vulnerabilities

Recent vulnerabilities recorded for convert-svg-core.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. 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