Malicious Code Injection in hardhat-option Package
Summary
MAL-2026-17660: Malicious code in hardhat-option (npm). Affects hardhat-option versions 2.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 hardhat-option package is a Node.js library designed to provide configuration options for Hardhat, a popular Ethereum development environment. This package is intended to simplify the development process for blockchain applications. However, it has been compromised, embedding malicious code that executes upon import, posing significant security risks to users.
Vulnerability Detail
The vulnerability in the hardhat-option package arises from its main index.js file, which immediately requires a heavily obfuscated lib/config module. This module is a large bundle that executes a malicious payload with the installer's privileges as soon as it is loaded. The package misrepresents itself by copying content from the pino package, creating confusion about its true identity. The obfuscation and auto-execution characteristics make it a classic loader/dropper, potentially leading to unauthorized access or data breaches.
How To Fix
This package is malicious. Remove it and rotate any credentials it could have accessed.
npm uninstall hardhat-option
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, consider removing the hardhat-option package from your project until a secure version is released. You can do this by running: npm uninstall hardhat-option.
Conclusion
The hardhat-option package has been compromised with malicious code that executes upon import, posing significant security risks. Users are advised to update the package to a patched version or remove it entirely until a fix is available. Utilizing tools like Vulert can help monitor for such vulnerabilities in real-time.
See every vulnerability recorded for hardhat-option →
FAQ
The hardhat-option package is a Node.js library that provides configuration options for the Hardhat Ethereum development environment.
The vulnerability allows malicious code to execute with the privileges of the user who installed the package, potentially leading to security breaches.
You can use Vulert to monitor and alert for open-source vulnerabilities in your software. Visit Vulert Scanner to check if your application is affected by this vulnerability.
Users should check the npm registry for any patched versions of the hardhat-option package and update accordingly.
As a temporary measure, uninstall the hardhat-option package from your project to mitigate the risk until a secure version is available.