Malicious code in chai-redirection (npm)
--- _-= Per source details. Do not edit below this line.=-_ ## Source: amazon-inspector (38236fbbdbbaa8f8ed9315c3a4ff01fbf049215896036b1cb68611681fe0eb00) chai-redirection presents itself as a chai assertion plugin but its main entry (index.js) unconditionally spawns a detached Node child process running lib/caller.js the moment the package is required. caller.js issues an HTTPS GET to https://www.jsonkeeper.com/b/PC5CK (a mutable pastebin-style host) and passes the response body's `cookie` field to `new Function('require', res.data.cookie)(require)`, executing attacker-controlled JavaScript in the installer's Node process with full `require` access. A secondary code path builds a URL from lib/config values, and on a 404 response whose body carries a `token` field, constructs `new Function.constructor('require', res.token)` and invokes it with `require` — a second remote-code-execution channel. The advertised chai plugin API (validJWT, safeString, etc.) is a cover story: the loader runs before any exports are used, so merely requiring this package as a chai plugin triggers remote code execution. The mutable pastebin source means today's payload can be replaced with anything at any time without republishing the package. ## Source: ghsa-malware (996d340e8231861ae21a30061eda3164b993e15bd08346375d8f886824b4fb6f) Any computer that has this package installed or running should be considered fully compromised. All secrets and keys stored on that computer should be rotated immediately from a different computer. The package should be removed, but as full control of the computer may have been given to an outside entity, there is no guarantee that removing the package will remove all malicious software resulting from installing it.
AI Analysis
Technical Summary
The chai-redirection npm package masquerades as a chai assertion plugin but contains embedded malicious code that triggers remote code execution immediately upon being required. Its main entry point spawns a detached Node child process that performs an HTTPS GET request to a mutable pastebin-style URL, retrieving JavaScript code from the response's 'cookie' field and executing it with full Node.js require privileges. A secondary code path fetches a token from a configurable URL and executes it similarly, providing a second remote code execution vector. Because the malicious code runs before any exports are accessed, simply requiring the package triggers execution of attacker-controlled code. The mutable external source allows the attacker to change the payload at any time without republishing the package, making the threat dynamic and persistent. This behavior effectively compromises any system that installs or runs this package.
Potential Impact
Any system that installs or runs the affected versions of chai-redirection is subject to immediate and full remote code execution by an attacker-controlled payload. This grants the attacker full control over the Node.js process environment, including access to require modules, enabling arbitrary code execution, data theft, and system compromise. Because the malicious code runs on package load, the risk exists even if the package's exported API is never used. The mutable external payload source means the attacker can update or change the malicious code at will, increasing the risk of ongoing compromise. Systems with this package should be considered fully compromised, and secrets or keys stored on them should be rotated from a trusted environment.
Mitigation Recommendations
No official patch or fix is currently available. The recommended mitigation is to immediately remove all affected versions (=0.0.1, =0.0.3, =0.0.4) of the chai-redirection package from all systems. Because the package executes attacker-controlled code with full privileges, any system that had this package installed or running should be treated as fully compromised. All secrets, credentials, and keys stored on the system should be rotated from a different, trusted machine. Additional forensic analysis and remediation may be necessary to ensure complete removal of any malicious artifacts. Monitor vendor advisories for any future updates or official fixes.
Malicious code in chai-redirection (npm)
Description
--- _-= Per source details. Do not edit below this line.=-_ ## Source: amazon-inspector (38236fbbdbbaa8f8ed9315c3a4ff01fbf049215896036b1cb68611681fe0eb00) chai-redirection presents itself as a chai assertion plugin but its main entry (index.js) unconditionally spawns a detached Node child process running lib/caller.js the moment the package is required. caller.js issues an HTTPS GET to https://www.jsonkeeper.com/b/PC5CK (a mutable pastebin-style host) and passes the response body's `cookie` field to `new Function('require', res.data.cookie)(require)`, executing attacker-controlled JavaScript in the installer's Node process with full `require` access. A secondary code path builds a URL from lib/config values, and on a 404 response whose body carries a `token` field, constructs `new Function.constructor('require', res.token)` and invokes it with `require` — a second remote-code-execution channel. The advertised chai plugin API (validJWT, safeString, etc.) is a cover story: the loader runs before any exports are used, so merely requiring this package as a chai plugin triggers remote code execution. The mutable pastebin source means today's payload can be replaced with anything at any time without republishing the package. ## Source: ghsa-malware (996d340e8231861ae21a30061eda3164b993e15bd08346375d8f886824b4fb6f) Any computer that has this package installed or running should be considered fully compromised. All secrets and keys stored on that computer should be rotated immediately from a different computer. The package should be removed, but as full control of the computer may have been given to an outside entity, there is no guarantee that removing the package will remove all malicious software resulting from installing it.
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The chai-redirection npm package masquerades as a chai assertion plugin but contains embedded malicious code that triggers remote code execution immediately upon being required. Its main entry point spawns a detached Node child process that performs an HTTPS GET request to a mutable pastebin-style URL, retrieving JavaScript code from the response's 'cookie' field and executing it with full Node.js require privileges. A secondary code path fetches a token from a configurable URL and executes it similarly, providing a second remote code execution vector. Because the malicious code runs before any exports are accessed, simply requiring the package triggers execution of attacker-controlled code. The mutable external source allows the attacker to change the payload at any time without republishing the package, making the threat dynamic and persistent. This behavior effectively compromises any system that installs or runs this package.
Potential Impact
Any system that installs or runs the affected versions of chai-redirection is subject to immediate and full remote code execution by an attacker-controlled payload. This grants the attacker full control over the Node.js process environment, including access to require modules, enabling arbitrary code execution, data theft, and system compromise. Because the malicious code runs on package load, the risk exists even if the package's exported API is never used. The mutable external payload source means the attacker can update or change the malicious code at will, increasing the risk of ongoing compromise. Systems with this package should be considered fully compromised, and secrets or keys stored on them should be rotated from a trusted environment.
Mitigation Recommendations
No official patch or fix is currently available. The recommended mitigation is to immediately remove all affected versions (=0.0.1, =0.0.3, =0.0.4) of the chai-redirection package from all systems. Because the package executes attacker-controlled code with full privileges, any system that had this package installed or running should be treated as fully compromised. All secrets, credentials, and keys stored on the system should be rotated from a different, trusted machine. Additional forensic analysis and remediation may be necessary to ensure complete removal of any malicious artifacts. Monitor vendor advisories for any future updates or official fixes.
Technical Details
- Gcve Source
- db.gcve.eu
- Osv Id
- MAL-2026-6995
- Osv Schema Version
- 1.7.4
- Aliases
- ["GHSA-89c7-5mf7-c86r"]
- Ecosystems
- ["npm"]
- Database Specific Severity
- null
- Cvss Version
- null
Threat ID: 6a50ba2f68715ace4357cff1
Added to database: 07/10/2026, 09:23:59 UTC
Last enriched: 07/10/2026, 09:29:45 UTC
Last updated: 07/30/2026, 19:52:57 UTC
Views: 22
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.