Malicious Code Injection in better-dotenv3 Package

better-dotenv3 Updated 25 Sep 2026

Summary

25/09/2026
CRITICAL
No i
Critical
Not published

MAL-2026-17172: Malicious code in better-dotenv3 (npm). Affects better-dotenv3 versions 1.0.1. 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 Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

The better-dotenv3 package is a Node.js library designed to load environment variables from a .env file into process.env. It is commonly used in JavaScript applications to manage configuration settings. However, this package has been identified as a typosquat, which means it mimics a legitimate package to deceive users. The malicious version executes harmful code upon being required in an application, posing significant security risks.

Vulnerability Detail

The vulnerability stems from the better-dotenv3 package being a typosquat that executes a hidden Windows loader on every require() and during CLI startup. It invokes a function that reads a bundled JPEG file, extracts a hidden payload, and executes it using PowerShell. This behavior is concealed through obfuscation techniques, making it difficult for static analysis tools to detect. The malicious code can lead to unauthorized access and control over the affected systems.

How To Fix

This package is malicious. Remove it and rotate any credentials it could have accessed.

npm uninstall better-dotenv3

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 workaround, you can avoid using the better-dotenv3 package altogether and switch to a trusted alternative like dotenv. To install dotenv, run: npm install dotenv. Make sure to update your code to use dotenv for loading environment variables.

Conclusion

The better-dotenv3 package has been identified as a malicious typosquat that executes harmful code, posing significant security risks. Users are advised to uninstall this package and switch to a trusted alternative. Regular monitoring of dependencies using tools like Vulert can help in identifying such vulnerabilities in the future.

See every vulnerability recorded for better-dotenv3 →

Share this vulnerability

FAQ

A typosquat is a malicious package that mimics a legitimate package name to trick users into installing it, often containing harmful code.

You can use Vulert, which monitors open-source vulnerabilities in real-time. Visit Vulert Scanner to check your application without any signup.

Immediately uninstall the better-dotenv3 package using npm uninstall better-dotenv3 and replace it with a trusted alternative like dotenv.

The malicious code executes by reading a hidden payload from a bundled JPEG file and running it through PowerShell, which can lead to unauthorized actions on the system.

No, there is no patch for better-dotenv3 as it is a malicious package. The best course of action is to remove it and use a legitimate alternative.

How To Fix

This package is malicious. Remove it and rotate any credentials it could have accessed.

npm uninstall better-dotenv3

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 →

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