Malicious code in chai-as-map (npm)
The npm package chai-as-map contains malicious obfuscated code that executes automatically on import. The package uses typosquatting (mimicking chai utilities), bundles legitimate pino logger source as cover, and executes a 4MB obfuscated payload at require time, likely functioning as a stealer/loader.
- Disclosed
- Last updated
- Blast radius
- Any npm consumer of chai-as-map package
- Ecosystems
- Attack vectors
- Affected entities
- chai-as-mapnpm package
The npm package chai-as-map was identified as malicious by the OpenSSF malicious-packages project. The package presents itself as a chai-related utility with keywords suggesting logging and stream functionality, but its actual purpose is to deliver obfuscated malicious code.
The package employs multiple deception techniques: it uses a name similar to legitimate chai packages (typosquatting), bundles verbatim source code from the legitimate pino logger library under lib/ as cover material, and declares an unrelated no-op Express middleware as its public API. The actual malicious payload is hidden in lib/config.js, a 4,083,409-byte obfuscated hex string array containing approximately 23,953 entries with rotated decoders and control-flow flattening.
The obfuscated code executes automatically when the module is imported via a require statement in index.js. The package also declares axios as a runtime dependency despite the advertised middleware performing no network I/O, suggesting the obfuscated payload reconstructs a remote destination at runtime for command-and-control communication.
This combination of typosquatting, legitimate code as cover, an unrelated public API, and auto-executing obfuscated payload is characteristic of a stealer or loader trojan delivered through package name confusion.
Indicators of compromise
- Packages
- chai-as-map
Remediation
- Remove chai-as-map from all dependencies immediately
- Audit npm install logs and lock files to identify when the package was installed
- Assume any system that imported chai-as-map has been compromised; rotate credentials, API keys, and secrets
- Scan affected systems for indicators of compromise from the obfuscated payload execution
- Review network logs for suspicious outbound connections from systems that imported the package
- Use npm audit to identify any other malicious packages in your dependency tree
Sources
- GitHub Advisory GHSA-rx7j-9w2g-fvjf · GitHub Advisory Database
Cite this entry
"Malicious code in chai-as-map (npm)." supplychainattack.org, Supply Chain Attack Incident Catalog. Disclosed August 10, 2026; last updated August 10, 2026. https://supplychainattack.org/incident/malicious-code-in-chai-as-map-npm-158z9w
Suggest a correction
Found an error or have a newer source? Corrections to factual errors take priority over new entries.
Related incidents
- resolvedcritical
Malicious code in github-policy-bot (npm)
The npm package github-policy-bot contained malicious code that exfiltrated host identifiers and environment metadata during installation via a postinstall script. The package name shadowed a legitimate Google-owned repository and was authored under a placeholder account claiming security research purposes.
npmCompromised packageTyposquatting - containedcritical
Malicious code in crypto-javas (npm)
The npm package crypto-javas contains malicious code in its postinstall hook and main entrypoint that harvests environment variables (including CI secrets like AWS_*, GITHUB_TOKEN, NPM_TOKEN) and exfiltrates them to an attacker-controlled backend. The package is presented deceptively as @wizlabs/js-crypto with a placeholder repository.
npmCompromised packageTyposquatting - resolvedcritical
Malicious code in react-dom-helpers (npm)
The npm package react-dom-helpers, a typosquat of the legitimate react-dom, contained malicious code that exfiltrated host identifiers (local IPv4 addresses, public IP, and system information) to a hardcoded Slack webhook on module load.
npmTyposquattingCompromised package - resolvedcritical
Malicious code in localize-extract (npm)
localize-extract@1.0.0 on npm contained malicious postinstall code that exfiltrated host identifiers to an attacker-controlled endpoint. The package name resembled @angular/localize, suggesting a dependency-confusion or typosquatting attack.
npmCompromised packageTyposquattingDependency confusion