Malicious code in chai-as-polished (npm)
The npm package 'chai-as-polished' is a malicious typosquat of the legitimate 'chai-as-promised' package. It contains code that spawns a detached child process which fetches and executes attacker-controlled JavaScript from a remote URL. This allows arbitrary code execution on any system that installs and invokes the package's middleware. The malicious payload is dynamically fetched from an anonymous hosting service, making it fully mutable by the attacker. Systems with this package installed should be considered fully compromised.
AI Analysis
Technical Summary
The 'chai-as-polished' npm package is a typosquatting malicious package impersonating 'chai-as-promised'. Its exported middleware spawns a detached, unreferenced child process running a script that constructs a fake environment variable object containing base64-encoded data. This data decodes to a URL hosted on an anonymous static hosting service and a secret header. The package uses axios to fetch a JSON resource from this URL, then executes the 'cookie' field from the response as JavaScript code with Node's require function available, enabling arbitrary attacker-controlled code execution. The base64 encoding is used to obfuscate the URL and header from cursory inspection. Execution requires the consumer to invoke the package's middleware, which is the documented entry point, thus deceiving users who install it by mistake.
Potential Impact
Any system that installs and runs the 'chai-as-polished' package and invokes its middleware is fully compromised. The attacker gains the ability to execute arbitrary code with the privileges of the Node.js process. This can lead to complete system takeover, data theft, credential compromise, and persistence of malicious software. All secrets and keys on the compromised system should be considered exposed and rotated immediately from a clean environment.
Mitigation Recommendations
Remove the 'chai-as-polished' package immediately from all affected systems. Rotate all secrets, keys, and credentials that were stored or accessible on the compromised machines from a different, trusted system. Do not rely solely on package removal, as the attacker may have installed additional backdoors or malware. Exercise caution to avoid installing similarly named typosquatting packages by verifying package names carefully before installation.
Malicious code in chai-as-polished (npm)
Description
The npm package 'chai-as-polished' is a malicious typosquat of the legitimate 'chai-as-promised' package. It contains code that spawns a detached child process which fetches and executes attacker-controlled JavaScript from a remote URL. This allows arbitrary code execution on any system that installs and invokes the package's middleware. The malicious payload is dynamically fetched from an anonymous hosting service, making it fully mutable by the attacker. Systems with this package installed should be considered fully compromised.
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-polished' npm package is a typosquatting malicious package impersonating 'chai-as-promised'. Its exported middleware spawns a detached, unreferenced child process running a script that constructs a fake environment variable object containing base64-encoded data. This data decodes to a URL hosted on an anonymous static hosting service and a secret header. The package uses axios to fetch a JSON resource from this URL, then executes the 'cookie' field from the response as JavaScript code with Node's require function available, enabling arbitrary attacker-controlled code execution. The base64 encoding is used to obfuscate the URL and header from cursory inspection. Execution requires the consumer to invoke the package's middleware, which is the documented entry point, thus deceiving users who install it by mistake.
Potential Impact
Any system that installs and runs the 'chai-as-polished' package and invokes its middleware is fully compromised. The attacker gains the ability to execute arbitrary code with the privileges of the Node.js process. This can lead to complete system takeover, data theft, credential compromise, and persistence of malicious software. All secrets and keys on the compromised system should be considered exposed and rotated immediately from a clean environment.
Mitigation Recommendations
Remove the 'chai-as-polished' package immediately from all affected systems. Rotate all secrets, keys, and credentials that were stored or accessible on the compromised machines from a different, trusted system. Do not rely solely on package removal, as the attacker may have installed additional backdoors or malware. Exercise caution to avoid installing similarly named typosquatting packages by verifying package names carefully before installation.
Technical Details
- Gcve Source
- db.gcve.eu
- Osv Id
- MAL-2026-5901
- Osv Schema Version
- 1.7.4
- Aliases
- ["GHSA-jpr9-h23w-g7gg"]
- Ecosystems
- ["npm"]
Threat ID: 6a4c342c27e9c797195fa589
Added to database: 07/06/2026, 23:03:08 UTC
Last enriched: 09/12/2026, 20:31:57 UTC
Last updated: 09/14/2026, 11:43:30 UTC
Views: 29
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.