Malicious Code Injection in hardhat-roof Package

hardhat-roof Updated 05 Oct 2026

Summary

04/10/2026
CRITICAL
No i
Critical
Not published

MAL-2026-17509: Malicious code in hardhat-roof (npm). Affects hardhat-roof 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-roof package is presented as a logger, mimicking the popular pino logger. It includes documentation and keywords that suggest it is a fast and efficient logging tool. However, the package is actually a doppelganger, with a misleading name and author, designed to execute malicious code upon import. This poses a significant risk to users who may unknowingly integrate it into their projects.

Vulnerability Detail

The vulnerability originates from the hardhat-roof package, which contains a large, obfuscated file (lib/config.js) that executes malicious code when the package is imported. This file is significantly larger than typical files found in legitimate packages and employs complex obfuscation techniques to hide its true purpose. Users who import this package inadvertently execute potentially harmful code, which could lead 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-roof

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-roof package entirely. Instead, use the legitimate pino logger or other trusted logging libraries. If you have already imported hardhat-roof, remove it from your dependencies and replace it with a secure alternative.

Conclusion

The hardhat-roof package poses a significant security risk due to its malicious code disguised as a legitimate logging tool. Users are advised to remove this package and replace it with trusted alternatives to safeguard their applications. Utilizing tools like Vulert can help in monitoring for such vulnerabilities in real-time.

See every vulnerability recorded for hardhat-roof →

Share this vulnerability

FAQ

The hardhat-roof package is a malicious package that pretends to be a logging tool similar to the pino logger but contains harmful code.

You can check your project's dependencies for the hardhat-roof package. Additionally, you can use Vulert to monitor and alert for vulnerabilities in your software.

Uninstall the hardhat-roof package immediately and replace it with a legitimate logging package like pino.

The malicious code is obfuscated and executes upon importing the package, potentially leading to unauthorized access or data breaches.

Yes, Vulert allows you to monitor and alert for open-source vulnerabilities in your software using just the package-lock.json file. You can check your application for vulnerabilities without needing to sign up.

How To Fix

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

npm uninstall hardhat-roof

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