Supply-chain threat intelligence

Incident detail

criticalnpm·typosquatting·osv

Malicious code in chai-as-persisted (npm)

chai-as-persisted

Risk score

92

AI summary

Indexed incident for chai-as-persisted (npm).

Description

The package's postinstall script (npm run smoke:pino) executes index.js, which spawns a detached node lib/initializeCaller.js child. That module hides the C2 URL in base64 strings stored under a fabricated local process.env object (keys DEV_API_KEY, DEV_SECRET_KEY, DEV_SECRET_VALUE) to defeat trivial string scanning. At install time it atob()-decodes the URL to https://www.ipregionchecker.org/api/ip-check-encrypted/3aeb34a37, POSTs to it via axios, and passes the response body to new Function.constructor('require', response), invoking it with require — executing attacker-controlled JavaScript with full Node module access on the installer's machine. The detached child.unref() keeps execution alive after npm install returns. The package name chai-as-persisted is a one-edit impersonation of the widely-used chai-as-promised; the shipped code is unrelated to chai (it pretends to be a pino-style logger middleware in index.js) and the package description/keywords (logger/stream/json) further misrepresent its purpose. This is a deliberate install-time RCE dropper distributed via a typosquat against chai-as-promised.

Any computer that has this package installed or running should be considered fully compromised. All secrets and keys stored on that computer should be rotated immediately from a different computer. The package should be removed, but as full control of the computer may have been given to an outside entity, there is no guarantee that removing the package will remove all malicious software resulting from installing it.

Technical details

Affected versions

=4.2.8=6.1.9>=0

Indicators

  • Advisory IDs
    90%
  • affected version=4.2.875%
  • affected version=6.1.975%
  • affected version>=075%

Timeline

  1. Advisory published
  2. Indexed by ThreatPkg

Related incidents