Malicious Code Injection in hardhat-lock Package - Critical Vulnerability Detected

hardhat-lock Updated 29 Sep 2026

Summary

28/09/2026
CRITICAL
No i
Critical
Not published

MAL-2026-17233: Malicious code in hardhat-lock (npm). Affects hardhat-lock 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 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 hardhat-lock package is an npm module designed to function as a logger and middleware for Ethereum development. However, it has been found to contain malicious code that compromises the integrity of applications using it. The package masquerades under a name similar to the well-known hardhat tool, which can mislead developers into trusting it. Its primary attributes include logging capabilities, but the actual implementation is deceptive and harmful.

Vulnerability Detail

The vulnerability originates from the hardhat-lock package version 2.21.0, which contains a significant amount of obfuscated code in its lib/config.js file. This file is a large, single-line script that executes immediately upon loading the package, allowing for unrestricted access to the consumer's Node.js environment. The malicious code can manipulate environment variables, access the filesystem, and perform network operations, posing a severe risk to any application that includes this package. The package's deceptive nature and obfuscation techniques make it a supply-chain attack vector, as it impersonates a legitimate package while executing harmful operations.

How To Fix

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

npm uninstall hardhat-lock

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, you can avoid using the hardhat-lock package altogether. If you have already integrated it into your application, ensure to audit your code and remove any references to it. Additionally, monitor your application for any unusual behavior that may arise from the malicious code.

Conclusion

The hardhat-lock package has been identified as containing malicious code that poses a significant risk to applications using it. Developers are urged to remove this package and replace it with trusted alternatives. Continuous monitoring of dependencies is essential to maintain application security.

See every vulnerability recorded for hardhat-lock →

Share this vulnerability

FAQ

The hardhat-lock package is an npm module intended for logging and middleware in Ethereum development, but it has been found to contain malicious code.

The vulnerability allows malicious code to execute within your application's Node.js process, potentially compromising sensitive data and system integrity.

You can use Vulert, which monitors and alerts for open-source vulnerabilities in real-time. Visit Vulert Scanner to check your application without needing to sign up.

Uninstall the hardhat-lock package immediately using npm uninstall hardhat-lock and replace it with a trusted logging library.

Yes, consider using reputable logging libraries such as 'pino' or 'winston' as alternatives for your logging needs.

How To Fix

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

npm uninstall hardhat-lock

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