Malicious Code Injection in Chai Logger Package - chai-logger Vulnerability
Summary
MAL-2026-16380: Malicious code in chai-logger (npm). Affects chai-logger versions 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 chai-logger package is designed as a logging plugin for the Chai assertion library, commonly used in JavaScript testing. It aims to enhance logging capabilities by providing structured output. However, this package has been found to contain malicious code that compromises its integrity and security, making it a significant risk for developers who rely on it for testing purposes.
Vulnerability Detail
The vulnerability originates from the package's main entry file, index.js, which requires a heavily obfuscated module located in lib/query.js. This module, approximately 4 MB in size, executes malicious code immediately upon import. The obfuscation techniques employed include a large rotated string array and hex-property indirection, making it difficult to analyze. The malicious payload is designed to steal credentials and data, utilizing an HTTP client declared within the obfuscated code. This situation is exacerbated by the presence of unrelated third-party code, which serves as a cover for the malicious functionality.
How To Fix
This package is malicious. Remove it and rotate any credentials it could have accessed.
npm uninstall chai-logger
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
If immediate updating is not feasible, consider removing the chai-logger package from your project and replacing it with a trusted alternative logging library that does not have known vulnerabilities. Additionally, you can monitor your dependencies using tools like Vulert, which can alert you to vulnerabilities in your open-source packages.
Conclusion
The chai-logger package has been identified as containing malicious code that poses a significant risk to applications using it. Developers are advised to update to a patched version or replace the package with a secure alternative. Continuous monitoring of dependencies is crucial to maintaining application security.
See every vulnerability recorded for chai-logger →
FAQ
Chai-logger is a logging plugin for the Chai assertion library, used primarily in JavaScript testing to enhance logging capabilities.
The malicious code can execute upon importing the package, potentially stealing sensitive data and credentials from your application.
You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.
Consider removing the chai-logger package and replacing it with a trusted alternative. Additionally, monitor your dependencies for vulnerabilities using tools like Vulert.
Detailed information about this vulnerability can be found in the Open Source Vulnerability database or by reviewing the package's repository for security advisories.