Skip to content
supplychainattack.orgSupply chain attack incident catalog
containedcritical

Malicious code in chai-as-format (npm)

The npm package chai-as-format contained malicious obfuscated code that executes automatically on import. The package impersonated the unrelated pino logging framework while shipping a ~4MB hex-encoded trojan loader disguised as a config module.

ShareXLinkedInHacker News
Disclosed
Last updated
Blast radius
Any developer or system that installed the malicious chai-as-format package from npm.
Ecosystems
Attack vectors
Affected entities
  • chai-as-formatnpm package containing obfuscated trojan loader

The npm package chai-as-format was found to contain malicious code in its index.js file, which unconditionally requires a ~4MB obfuscated module named ./lib/config. This obfuscated code uses obfuscator.io-style encoding with a 23,953-entry hex-encoded string array and heavy control-flow flattening, executing automatically whenever the package is imported.\n\nThe package employed a deceptive impersonation strategy: its README, LICENSE, and documentation were copied from the unrelated pino logging framework (with LICENSE attribution to pinojs/pino), while the package.json description referenced vulnerability management. This mismatch between the cover story and actual shipped content indicates intentional obfuscation of the package's true purpose.\n\nThe multi-megabyte opaque decoder auto-loaded on import is not a legitimate configuration module but rather a trojan loader hidden behind an impersonation shell. The malicious code would execute on the installer's machine whenever the package was required.\n\nThe incident was identified and credited to the OpenSSF's malicious-packages repository.

Indicators of compromise

Packages
  • chai-as-format

Remediation

  • Immediately remove chai-as-format from all projects and dependencies
  • Audit npm install logs to identify when the package was installed
  • Review systems where the package was installed for signs of compromise or unauthorized activity
  • Regenerate any credentials or signing keys that may have been exposed on affected systems
  • Update to a legitimate alternative if the intended functionality is needed
  • Check npm audit and dependency scanning tools for detection of this malicious package

Sources

  1. GitHub Advisory GHSA-wpwv-ffg9-hmxr · GitHub Advisory Database

Cite this entry

"Malicious code in chai-as-format (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-format-npm-hu3vzg

Suggest a correction

Found an error or have a newer source? Corrections to factual errors take priority over new entries.

  1. activecritical

    Malware in bolt-delivery-menu-app

    The npm package bolt-delivery-menu-app contains malware that grants full control of affected systems. Any computer with this package installed or running should be considered fully compromised.

    npmCompromised package
  2. containedcritical

    Malware in a.poltoradnev-package-a

    The npm package a.poltoradnev-package-a contains malware that grants full system compromise to attackers. Any computer with this package installed should be considered fully compromised and all secrets and keys rotated immediately from a different machine.

    npmCompromised package
  3. containedcritical

    Malware in @junofficial/baileys

    The npm package @junofficial/baileys contained malware that fully compromised any system with the package installed or running. The malicious package has been identified and removed from distribution.

    npmCompromised package
  4. containedcritical

    Malware in userbotjs

    The npm package userbotjs contained malware that could fully compromise any system on which it was installed. The advisory recommends treating affected systems as fully compromised and rotating all secrets and keys from a different computer.

    npmCompromised package