Malicious Code Execution Vulnerability in pixsvg Package
Summary
MAL-2026-17313: Malicious code in pixsvg (npm). Affects pixsvg versions 0.2.0. No fix is published. How to fix ↓
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.
No signup required · Results in about 60 seconds
Background
The pixsvg package is a JavaScript library designed for processing SVG (Scalable Vector Graphics) files. It allows developers to manipulate SVG data and integrate it into web applications. However, the package has been found to contain a serious vulnerability that enables the execution of arbitrary JavaScript code, posing a significant security risk to applications that utilize it.
Vulnerability Detail
The vulnerability originates from the pixsvg module's export of the function fetchDataFromSvg(svgData). This function scans input SVG data for a specific comment format that embeds JavaScript code in a binary-encoded sequence. The function then reconstructs this sequence into a JavaScript string and executes it using eval(). This covert execution channel allows attackers to run malicious code in the host process, potentially leading to data breaches, unauthorized access, or other malicious activities. The function is publicly accessible but undocumented, making it a hidden threat for developers who may unknowingly expose their applications to risks by using this function.
How To Fix
This package is malicious. Remove it and rotate any credentials it could have accessed.
npm uninstall pixsvg
If it arrived as a transitive dependency, remove the package that pulled it in, then reinstall.
Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →
Workaround
As a temporary workaround, avoid using the fetchDataFromSvg function in your application. Instead, consider using alternative methods for processing SVG data that do not involve executing JavaScript from untrusted sources.
Conclusion
The pixsvg package contains a critical vulnerability that allows for the execution of malicious JavaScript code through improperly handled SVG data. It is essential for developers using this package to update to the latest version and avoid using the vulnerable function to mitigate potential security risks.
See every vulnerability recorded for pixsvg →
FAQ
The vulnerability allows for the execution of arbitrary JavaScript code embedded within SVG files, which can lead to security breaches.
You can use Vulert, a tool that monitors and alerts for open-source vulnerabilities, to check if your application is affected by this vulnerability.
If you cannot update the package, avoid using the vulnerable function fetchDataFromSvg and consider alternative methods for handling SVG data.
Yes, there is a risk of data loss or unauthorized access if an attacker exploits this vulnerability to execute malicious code.
More information can be found in the vulnerability report on the official GitHub repository or through security advisories related to the pixsvg package.