Malicious Code Detected in TensorFlow.js Package: Security Risk Alert
Summary
MAL-2025-6829: Malicious code in tensorflowjs (npm). Affects tensorflowjs versions 0.6.8 – 0.7.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
TensorFlow.js is a popular library for machine learning in JavaScript, enabling developers to build and train models directly in the browser or in Node.js. It is widely used for various applications, including image recognition and natural language processing. However, the package has been compromised, introducing significant security risks due to malicious code embedded within it.
Vulnerability Detail
The vulnerability stems from malicious code that has been intentionally obfuscated within the TensorFlow.js package. This code allows for arbitrary command execution via the 'child_process.spawn' method, which can lead to unauthorized access and control over the system where the package is installed. The presence of a suspicious 'postinstall' script further exacerbates the risk, as it executes automatically upon installation, potentially compromising the user's environment.
How To Fix
This package is malicious. Remove it and rotate any credentials it could have accessed.
npm uninstall tensorflowjs
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 TensorFlow.js package until a secure version is confirmed. Additionally, consider using alternative libraries for machine learning tasks that do not have known vulnerabilities.
Conclusion
The TensorFlow.js package has been compromised with malicious code that poses a serious security threat. It is essential for users to take immediate action by uninstalling the affected version and updating to a secure release. Utilizing tools like Vulert can help monitor and manage vulnerabilities effectively.
See every vulnerability recorded for tensorflowjs →
FAQ
The vulnerability involves malicious code that allows for arbitrary command execution, posing a significant security risk.
You can use Vulert, which monitors and alerts for open-source vulnerabilities in real-time. Visit Vulert Scanner to check your application without any signup.
Immediately uninstall the affected version using 'npm uninstall tensorflowjs' and install the latest secure version with 'npm install tensorflowjs@latest'.
Regularly monitor your dependencies using tools like Vulert and keep your packages updated to the latest versions to mitigate risks.
Failure to address this vulnerability could lead to unauthorized access to your system, data breaches, and potential exploitation by malicious actors.