Malicious code in chai-as-persisted (npm)
The npm package 'chai-as-persisted' is a malicious typosquatting package impersonating the legitimate 'chai-as-promised' package. Its postinstall script executes attacker-controlled JavaScript by decoding a hidden command-and-control URL and running code fetched from it, resulting in remote code execution (RCE) on the installer's machine. The malicious code runs detached from the install process, maintaining persistence beyond installation. Installing this package fully compromises the affected system, risking exposure of all stored secrets and keys.
AI Analysis
Technical Summary
The 'chai-as-persisted' npm package contains a postinstall script that executes 'index.js', which spawns a detached child process running 'lib/initializeCaller.js'. This module hides a base64-encoded C2 URL in fabricated environment variables to evade detection. At install time, it decodes the URL, sends a POST request to it, and executes the response as JavaScript with full Node.js module access via 'new Function.constructor'. This results in remote code execution on the installer's machine. The package is a deliberate typosquat of 'chai-as-promised' with unrelated malicious code masquerading as a logger middleware.
Potential Impact
Any system that installs or runs this package is fully compromised due to the execution of attacker-controlled code with full Node.js access. This can lead to unauthorized access, data theft, and persistent backdoors. All secrets and keys stored on the compromised system should be considered exposed and must be rotated immediately. Removing the package does not guarantee removal of all malicious artifacts or backdoors.
Mitigation Recommendations
Remove the 'chai-as-persisted' package immediately from all affected systems. Rotate all secrets and keys that were stored or accessible on the compromised machines using a secure, unaffected environment. Because the attacker gains full control during installation, assume the system is fully compromised and consider rebuilding or thoroughly auditing the environment. There is no official patch or fix for this malicious package; prevention relies on avoiding installation of typosquatting packages and verifying package authenticity.
Malicious code in chai-as-persisted (npm)
Description
The npm package 'chai-as-persisted' is a malicious typosquatting package impersonating the legitimate 'chai-as-promised' package. Its postinstall script executes attacker-controlled JavaScript by decoding a hidden command-and-control URL and running code fetched from it, resulting in remote code execution (RCE) on the installer's machine. The malicious code runs detached from the install process, maintaining persistence beyond installation. Installing this package fully compromises the affected system, risking exposure of all stored secrets and keys.
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-as-persisted' npm package contains a postinstall script that executes 'index.js', which spawns a detached child process running 'lib/initializeCaller.js'. This module hides a base64-encoded C2 URL in fabricated environment variables to evade detection. At install time, it decodes the URL, sends a POST request to it, and executes the response as JavaScript with full Node.js module access via 'new Function.constructor'. This results in remote code execution on the installer's machine. The package is a deliberate typosquat of 'chai-as-promised' with unrelated malicious code masquerading as a logger middleware.
Potential Impact
Any system that installs or runs this package is fully compromised due to the execution of attacker-controlled code with full Node.js access. This can lead to unauthorized access, data theft, and persistent backdoors. All secrets and keys stored on the compromised system should be considered exposed and must be rotated immediately. Removing the package does not guarantee removal of all malicious artifacts or backdoors.
Mitigation Recommendations
Remove the 'chai-as-persisted' package immediately from all affected systems. Rotate all secrets and keys that were stored or accessible on the compromised machines using a secure, unaffected environment. Because the attacker gains full control during installation, assume the system is fully compromised and consider rebuilding or thoroughly auditing the environment. There is no official patch or fix for this malicious package; prevention relies on avoiding installation of typosquatting packages and verifying package authenticity.
Technical Details
- Gcve Source
- db.gcve.eu
- Osv Id
- MAL-2026-6544
- Osv Schema Version
- 1.7.4
- Aliases
- ["GHSA-4wm6-vmww-2544"]
- Ecosystems
- ["npm"]
- Database Specific Severity
- null
- Cvss Version
- null
Threat ID: 6a4452f127e9c797198f5108
Added to database: 06/30/2026, 23:36:17 UTC
Last enriched: 06/30/2026, 23:56:42 UTC
Last updated: 07/28/2026, 13:52:14 UTC
Views: 17
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.
External Links
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.