Critical Malicious Code Vulnerability in react-hook-form-persist Package
Summary
MAL-2025-190990: Malicious code in react-hook-form-persist (npm). Affects react-hook-form-persist versions 3.0.1 – 3.0.2. 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 react-hook-form-persist package is a popular library in the npm ecosystem that facilitates the persistence of form data in React applications. It allows developers to save form state in local storage, enhancing user experience by retaining input data across sessions. However, this package has been found to contain malicious code, compromising the security of any application that utilizes it.
Vulnerability Detail
The vulnerability stems from the inclusion of malicious code within the react-hook-form-persist package. This code can lead to a complete compromise of any system where the package is installed, allowing unauthorized access to sensitive information such as secrets and keys. The malicious nature of the code has been confirmed by multiple sources, including Amazon Inspector and GHSA malware reports, indicating that the package should be treated as a severe security threat.
How To Fix
This package is malicious. Remove it and rotate any credentials it could have accessed.
npm uninstall react-hook-form-persist
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 measure, you can avoid using the react-hook-form-persist package and implement your own form persistence logic using local storage or other methods. For example, you can manually save form data to local storage like this:
const saveFormData = (data) => {
localStorage.setItem('formData', JSON.stringify(data));
};
const loadFormData = () => {
return JSON.parse(localStorage.getItem('formData')) || {};
};
Conclusion
The discovery of malicious code in the react-hook-form-persist package poses a significant risk to applications using it. Immediate action is required to mitigate potential damage, including uninstalling the package and rotating sensitive information. Users are encouraged to monitor their systems for any signs of compromise.
See every vulnerability recorded for react-hook-form-persist →
FAQ
It is a library that helps persist form data in React applications, allowing data to be saved in local storage.
The malicious code can compromise your system, allowing unauthorized access to sensitive information and potentially leading to data breaches.
You should immediately uninstall the package and rotate any secrets or keys that may have been exposed.
Yes, you can use Vulert, which monitors and alerts for open-source vulnerabilities in real-time. You can check your application using the Vulert playground without any signup.
While removing the package is essential, there is no guarantee that all malicious software resulting from its installation will be removed. A thorough security audit of your system is recommended.