Malicious Code Injection in hardhat-ftp Package
Summary
MAL-2026-17506: Malicious code in hardhat-ftp (npm). Affects hardhat-ftp 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-ftp package is an npm module designed to facilitate FTP operations within the Hardhat development environment. It is intended to provide developers with a streamlined way to manage file transfers during the development process. However, this package has been compromised, embedding malicious code that poses significant security risks to users.
Vulnerability Detail
The vulnerability originates from the hardhat-ftp package's main entry point, index.js, which unconditionally requires a large obfuscated file located at /lib/config. This file, packed using obfuscator.io, executes malicious code as soon as the package is required. The obfuscation conceals the true nature of the code, which includes outbound HTTP requests and local command execution capabilities. This means that any user who installs or requires this package inadvertently executes attacker-controlled code, leading to potential data breaches or system compromises.
How To Fix
This package is malicious. Remove it and rotate any credentials it could have accessed.
npm uninstall hardhat-ftp
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-ftp package altogether until a secure version is released. If you must use it, consider isolating the environment in which it runs to minimize potential damage.
Conclusion
The hardhat-ftp package has been compromised with malicious code that executes upon installation. Users are advised to uninstall the package and seek alternatives to mitigate the risks associated with this vulnerability. Regular monitoring for vulnerabilities is essential to maintain the security of your projects.
See every vulnerability recorded for hardhat-ftp →
FAQ
The hardhat-ftp package is an npm module designed to facilitate FTP operations within the Hardhat development environment.
The malicious code executes automatically when the package is required in a project, due to the unconditioned require statement in index.js.
The risks include unauthorized access to sensitive data, potential system compromise, and the execution of arbitrary commands on the user's machine.
You can use Vulert, which monitors and alerts in real-time for open-source vulnerabilities using just the package-lock.json file. Visit https://vulert.com for more information.
Yes, you can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.