Critical Malicious Code Vulnerability in chai-as-mock Package
Summary
MAL-2026-1191: Malicious code in chai-as-mock (npm). Affected versions are not published. 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 chai-as-mock package is an npm library designed to facilitate mocking in tests using the Chai assertion library. It allows developers to create mock objects and functions, enhancing the testing process by providing a way to simulate complex behaviors. However, this package has been compromised, embedding malicious code that poses significant security risks to any system utilizing it.
Vulnerability Detail
The vulnerability stems from the presence of malicious code within the chai-as-mock package, identified by the alias GHSA-vp25-hhqc-cx25. Any system with this package installed is considered fully compromised, potentially allowing unauthorized access to sensitive information such as secrets and keys. The malicious code can lead to severe ramifications, including data breaches and loss of control over the affected system. Users are advised to treat any system with this package as compromised and take immediate action.
How To Fix
This package is malicious. Remove it and rotate any credentials it could have accessed.
npm uninstall chai-as-mock
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
There are no effective workarounds for this vulnerability other than removing the package entirely. Ensure that your application does not rely on chai-as-mock for mocking functionality, and consider using alternative libraries that are secure.
Conclusion
The discovery of malicious code in the chai-as-mock package poses a significant threat to users. Immediate action is required to remove the package and secure any sensitive information. Users are encouraged to utilize tools like Vulert to monitor their applications for vulnerabilities and ensure ongoing security.
See every vulnerability recorded for chai-as-mock →
FAQ
Immediately uninstall the package using npm uninstall chai-as-mock and rotate any sensitive information stored on the affected system.
You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without any signup.
Failing to address this vulnerability can lead to unauthorized access to sensitive data, potential data breaches, and loss of control over your system.
The only effective mitigation is to remove the package entirely, as there are no safe workarounds available.
Yes, you can report vulnerabilities to the maintainers of the package or through platforms like GitHub to help raise awareness.