Malicious Code Execution Vulnerability in dotenv-native Package
Summary
MAL-2026-17231: Malicious code in dotenv-native (npm). Affects dotenv-native versions 1.0.1. 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 dotenv-native package is a Node.js library that typosquats the popular dotenv family, which is widely used for loading environment variables from a .env file into process.env. This package is intended to simplify the management of environment variables in Node.js applications. However, it has been found to contain malicious code that executes an attacker-controlled payload upon loading the module, posing significant security risks to applications that depend on it.
Vulnerability Detail
The vulnerability originates from the dotenv-native package, which executes a malicious payload when the module is loaded. Specifically, the package contains a routine that opens a bundled JPEG file, scans it for an APP1/EXIF marker, and extracts the contents to execute a command using PowerShell. This is achieved through a series of obfuscation techniques to evade detection. The malicious code can lead to remote code execution (RCE) on Windows hosts, compromising the security of affected systems.
How To Fix
This package is malicious. Remove it and rotate any credentials it could have accessed.
npm uninstall dotenv-native
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, you can avoid using the dotenv-native package and ensure that your application does not load it as a dependency. Regularly audit your dependencies to ensure that no malicious packages are included.
Conclusion
The dotenv-native package contains a serious vulnerability that can lead to remote code execution on affected systems. It is crucial to remove this package and replace it with a secure alternative to protect your applications from potential attacks. Regular monitoring and auditing of dependencies are essential for maintaining security.
See every vulnerability recorded for dotenv-native →
FAQ
dotenv-native is a Node.js package that is intended to load environment variables from a .env file, but it has been found to contain malicious code.
The vulnerability allows an attacker to execute arbitrary code on your system, potentially leading to data breaches or system compromise.
You can use Vulert, which monitors and alerts for open-source vulnerabilities in your software. You can check your application using the Vulert playground without any signup.
You should uninstall dotenv-native immediately and replace it with the legitimate dotenv package to mitigate the risk.
Regularly audit your dependencies, keep your packages updated, and use tools like Vulert to monitor for vulnerabilities.