Malicious Code Execution in hardhat-kex Package
Summary
MAL-2026-17559: Malicious code in hardhat-kex (npm). Affects hardhat-kex 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-kex package, version 2.0.1, is an npm package designed for the Hardhat/Ethereum ecosystem, purportedly functioning as a vulnerability-management tool. However, it contains an obfuscated 4.5MB single-line bundle that executes malicious code upon import, misleading users with unrelated Express middleware and bundled files from the pino logging library.
Vulnerability Detail
The vulnerability arises from the inclusion of obfuscated code in the hardhat-kex package, which executes automatically when the package is imported. This malicious code is designed to run without the user's consent or knowledge, potentially leading to unauthorized actions within the user's environment. The package's misleading name and description, combined with unrelated files, serve as a decoy to mask the true nature of the code, making it a significant security risk for any project that includes it as a dependency.
How To Fix
This package is malicious. Remove it and rotate any credentials it could have accessed.
npm uninstall hardhat-kex
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
There are no specific workarounds to mitigate the effects of this vulnerability other than removing the package from your dependencies.
Conclusion
The hardhat-kex package contains a serious vulnerability due to the presence of obfuscated malicious code that executes upon import. Users are advised to remove this package from their projects to prevent potential security risks. Monitoring tools like Vulert can help in identifying such vulnerabilities in the future.
See every vulnerability recorded for hardhat-kex →
FAQ
The hardhat-kex package is an npm package intended for the Hardhat/Ethereum ecosystem, claiming to provide vulnerability management tools.
The vulnerability manifests as obfuscated code that executes automatically when the package is imported, without any user interaction.
Using hardhat-kex poses significant risks, including potential unauthorized actions in your environment due to the execution of malicious code.
Yes, you can use Vulert, which monitors and alerts in real-time for open-source vulnerabilities using just your package-lock.json file. You can check for vulnerabilities in your application using the Vulert playground without any signup.
If you have used hardhat-kex, you should immediately uninstall it and review your project for any potential impacts caused by the malicious code.