Remote Code Execution Vulnerability in hardhat-base Package
Summary
MAL-2026-16348: Malicious code in hardhat-base (npm). Affects hardhat-base versions 2.2.0 – 2.2.2. 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-base package is a logger that claims compatibility with the popular Pino logging library. It is designed to facilitate logging in Node.js applications, providing features such as fast logging, JSON output, and middleware support. However, this package has been compromised, leading to a significant security vulnerability that allows for remote code execution (RCE).
Vulnerability Detail
The vulnerability originates from a malicious code embedded within the hardhat-base package. When the middleware is invoked, it spawns a child process that retrieves a base64-encoded URL from a fake environment variable. This URL points to an attacker-controlled endpoint, which, when accessed, returns arbitrary JavaScript code. This code is executed with full Node.js require access, allowing attackers to run any code on the victim's machine. The intentional design of this attack, including the use of fake environment variables and a misleading package description, indicates a supply-chain attack rather than a mere coding oversight.
How To Fix
This package is malicious. Remove it and rotate any credentials it could have accessed.
npm uninstall hardhat-base
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 hardhat-base package until it has been updated. If you must use it, consider implementing additional security measures such as sandboxing your Node.js environment to limit the execution of untrusted code.
Conclusion
The hardhat-base package has been compromised, leading to a serious remote code execution vulnerability. Users are advised to update to the latest version immediately and consider using tools like Vulert for ongoing monitoring of their dependencies. Understanding and addressing such vulnerabilities is crucial for maintaining secure applications.
See every vulnerability recorded for hardhat-base →
FAQ
The vulnerability allows for remote code execution due to malicious code embedded in the package, which can execute arbitrary JavaScript on the user's machine.
You can use Vulert to monitor and alert for open-source vulnerabilities in your software. Simply upload your package-lock.json file to the Vulert playground at Vulert Scanner to check for vulnerabilities.
If an immediate update is not possible, consider implementing security measures such as sandboxing your Node.js environment to mitigate the risk of executing untrusted code.
Regularly audit your dependencies and use tools like Vulert to monitor for vulnerabilities in your open-source packages. Keeping your packages updated is crucial for security.
If exploited, this vulnerability can lead to unauthorized access to your system, data theft, or complete control over your application environment, posing significant security risks.