# MAL-2026-5902: Malicious code in chai-as-tokenized (npm)


- **Type:** Malicious package
- **Package:** `chai-as-tokenized` (npm)
- **Published:** 16 Jun 2026
- **Also known as:** GHSA-4hvx-q2w4-f48v

## What is MAL-2026-5902?

MAL-2026-5902 is a malicious package in chai-as-tokenized, published on 16 Jun 2026. 

### Official description

Package name impersonates chai-as-promised, and the README is a copy of pino's documentation, but the actual code is a remote-code-execution dropper. The exported middleware (advertised as `chai.use(chaiAsTokenized)`) spawns lib/initializeCaller.js as a detached `node` child with `stdio:'ignore'` and `child.unref()`, hiding output and surviving parent exit. The child shadows the `process` global with a fake object whose env values are base64 strings, atob-decodes them to obtain `https://amethyst-lorrin-26.tiiny.site/index.json` and the header `x-secret-key: _`, fetches JSON from that anonymous tiiny.site endpoint, and passes the response's `cookie` field to `new Function.constructor('require', response)` invoked with the live `require` — granting the remote, attacker-controlled host arbitrary code execution inside the consuming process with full module access. Combined signals: name-impersonation of a popular chai plugin, README mismatch with shipped code, base64-obfuscated C2 URL, anonymous static-file host (not a publisher domain), detached-and-silenced child spawn, and remote response evaluated as JavaScript.

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.

## What should I do about MAL-2026-5902?

Remove the package from your dependencies and lockfiles, then rotate any secrets on machines where it was installed.

## Fix prompt for AI coding agents

```text
MAL-2026-5902 is a malicious package: chai-as-tokenized (npm). Every version was published to cause harm.

Task:
1. Search this repository's dependency manifests and lockfiles for the package, including transitive dependencies.
2. If it is present, remove it, regenerate the lockfile with the project's package manager, and replace whatever it was used for.
3. List any CI runners, developer machines or containers that installed it, so their secrets can be rotated.
4. If the package is not used anywhere, say so and change nothing.

Reference: https://insights.sbomify.com/MAL-2026-5902/ (Markdown: https://insights.sbomify.com/MAL-2026-5902/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/MAL-2026-5902

---
From sbomify Insights: https://insights.sbomify.com/MAL-2026-5902/
Summaries are generated and may contain mistakes; the official description above is the record.
