Malicious Code Injection in hardhat-init Package

hardhat-init Updated 06 Oct 2026

Summary

06/10/2026
CRITICAL
No i
Critical
Not published

MAL-2026-17636: Malicious code in hardhat-init (npm). Affects hardhat-init versions 2.21.0. 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 MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

The hardhat-init package is designed to facilitate the initialization of Hardhat projects, a popular framework for Ethereum development. It aims to streamline the setup process for developers by providing essential tools and configurations. However, this package has been compromised, leading to significant security risks due to the presence of malicious code.

Vulnerability Detail

The vulnerability in the hardhat-init package arises from the inclusion of a heavily obfuscated JavaScript file (lib/config.js) that executes arbitrary code upon loading the package. This obfuscation employs techniques such as hex-escaped string tables and nested index-lookup helpers, making it difficult to discern the malicious behavior. The package's misleading name and content further exacerbate the issue, as it masquerades as a legitimate initialization tool while executing harmful code on the user's machine.

How To Fix

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

npm uninstall hardhat-init

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-init package until a secure version is released. Instead, consider manually initializing your Hardhat projects by following the official Hardhat documentation.

Conclusion

The hardhat-init package has been compromised with malicious code that executes upon loading. It is essential to update or remove this package to protect your system from potential threats. Utilize tools like Vulert to monitor your applications for vulnerabilities and ensure a secure development environment.

See every vulnerability recorded for hardhat-init →

Share this vulnerability

FAQ

The hardhat-init package is a tool designed to help developers initialize Hardhat projects for Ethereum development.

The malicious code can execute arbitrary commands on your machine, potentially leading to data theft, system compromise, or other harmful actions.

You can use Vulert, which monitors and alerts for open-source vulnerabilities in real-time. Visit Vulert Scanner to check your application without requiring access to the code or installation.

If you have installed the hardhat-init package, immediately remove it and update your project dependencies to eliminate the risk of executing malicious code.

Yes, always stay informed about vulnerabilities in the packages you use. Regularly check for updates and utilize tools like Vulert to monitor your dependencies.

How To Fix

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

npm uninstall hardhat-init

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