Skip to main content

Malicious code in chai-as-polished (npm)

0
Critical
Published: 06/16/2026 (06/16/2026, 16:22:51 UTC)
Source: GCVE Database
Product: chai-as-polished

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

npmghsa
chai-as-polished
Affected versions
=7.0.8

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

AILast updated: 09/12/2026, 20:31:57 UTC

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.

Pro Console: star threats, build custom feeds, automate alerts via Slack, email & webhooks.Upgrade to Pro

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 reviews

Crowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.

Sort by
Loading community insights…

Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.

Actions

PRO

Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.

Please log in to the Console to use AI analysis features.

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

Breach by OffSeqOFFSEQFRIENDS — 25% OFF

Check if your credentials are on the dark web

Instant breach scanning across billions of leaked records. Free tier available.

Scan now
OffSeq TrainingCredly Certified

Lead Pen Test Professional

Technical5-day eLearningPECB Accredited
View courses