Malicious code in js-assert-plus (npm)
The npm package js-assert-plus contained malicious code that executed attacker-controlled JavaScript on installation. The package masqueraded as an assertion library while bundling legitimate chai source, but injected a loader that spawned a subprocess to fetch and execute remote code via obfuscated string reconstruction.
- Disclosed
- Last updated
- Blast radius
- All npm consumers of js-assert-plus package
- Ecosystems
- Attack vectors
- Affected entities
- js-assert-plusnpm package masquerading as assertion library
The npm package js-assert-plus was identified as malicious by Amazon Inspector and the OpenSSF. The package masqueraded as a legitimate assertion library with a homepage at http://js-assert-plus.com and bundled real chai source code to provide working functionality to consumers.
However, the package's index.js contained malicious code that hex-decoded the strings 'child_process' and 'spawn' to hide them from static analysis, then spawned a detached Node.js subprocess running lib/chai/utils/assertion.js. This sibling module was heavily obfuscated using obfuscator.io string-array obfuscation with a rotated array and base64+decodeURIComponent decoder.
At runtime, the obfuscated code reconstructed a URL, performed an HTTPS GET request, and passed the response body to new Function('require', body)(require), executing arbitrary attacker-controlled JavaScript with require in scope on the installer's machine. Both the require of child_process and the network destination were hidden behind runtime string reconstruction to evade static inspection.
The malicious package was discovered and reported by the OpenSSF's malicious-packages repository.
Indicators of compromise
- Packages
- js-assert-plus
Remediation
- Immediately uninstall js-assert-plus from all systems and projects
- Audit npm package.json and lock files for any presence of js-assert-plus
- Review system logs and network traffic from machines where js-assert-plus was installed for signs of compromise
- Replace js-assert-plus with a legitimate assertion library such as chai or assert
- Implement npm package verification and scanning in CI/CD pipelines to detect malicious packages
- Monitor for any suspicious activity or data exfiltration from affected systems
Sources
- GitHub Advisory GHSA-p5h5-frw5-5prg · GitHub Advisory Database
Cite this entry
"Malicious code in js-assert-plus (npm)." supplychainattack.org, Supply Chain Attack Incident Catalog. Disclosed August 13, 2026; last updated August 13, 2026. https://supplychainattack.org/incident/malicious-code-in-js-assert-plus-npm-1ywujr
Suggest a correction
Found an error or have a newer source? Corrections to factual errors take priority over new entries.
Related incidents
- containedcritical
Malicious code in 3-buildsight-web (npm)
The npm package 3-buildsight-web contains malicious code that fetches and executes arbitrary JavaScript from a remote Bitbucket URL on module load, granting full page privileges to an unverified third party.
npmCompromised package - resolvedcritical
Malicious code in @usaa-grp-personal-profile/personal-profile-common (npm)
Malicious package @usaa-grp-personal-profile/personal-profile-common version 999.0.0 published to public npm as a dependency-confusion attack targeting an organization's internal registry. The package contains preinstall and postinstall hooks that exfiltrate hostname, username, and working directory to an attacker-controlled OAST endpoint on every install.
npmDependency confusionCompromised package - resolvedcritical
Malicious code in create-coin (npm)
create-coin@20.1.1 on npm contained malicious postinstall code that collected sensitive environment variables, credentials, and host reconnaissance data. The package impersonated an esbuild platform build and exfiltrated data to a hardcoded endpoint.
npmCompromised packageTyposquatting - resolvedcritical
Malicious code in @syncraft-labs/vue (npm)
The npm package @syncraft-labs/vue version 0.4.1 contained malicious obfuscated code in its ESM build that implements a blockchain-hosted C2 dropper (EtherHiding pattern), enabling remote code execution on any consumer importing the package.
npmCompromised package