{"id":"MAL-2026-5902","summary":"Malicious code in chai-as-tokenized (npm)","details":"\n---\n_-= Per source details. Do not edit below this line.=-_\n\n## Source: amazon-inspector (55c10da182a0c79ca5eb0f85c6b2e334b7ee4e90946dfcc34feb44e80afa4485)\nPackage 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.\n\n## Source: ghsa-malware (fe8e4af381c4b8eb3ff6a93cbd50f27cd0196c86038024c04ad803780f72cae9)\nAny 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.\n","aliases":["GHSA-4hvx-q2w4-f48v"],"modified":"2026-06-17T15:31:51.654428361Z","published":"2026-06-16T16:22:50Z","database_specific":{"malicious-packages-origins":[{"sha256":"55c10da182a0c79ca5eb0f85c6b2e334b7ee4e90946dfcc34feb44e80afa4485","import_time":"2026-06-16T18:10:20.637057475Z","source":"amazon-inspector","versions":["7.2.3"],"id":"IN-MAL-2026-006793","modified_time":"2026-06-16T16:22:50Z"},{"sha256":"fe8e4af381c4b8eb3ff6a93cbd50f27cd0196c86038024c04ad803780f72cae9","source":"ghsa-malware","import_time":"2026-06-17T15:23:59.027578683Z","ranges":[{"type":"SEMVER","events":[{"introduced":"0"}]}],"id":"GHSA-4hvx-q2w4-f48v","modified_time":"2026-06-17T13:59:28Z"}]},"references":[{"type":"PACKAGE","url":"https://www.npmjs.com/package/chai-as-tokenized/v/7.2.3"},{"type":"ADVISORY","url":"https://github.com/advisories/GHSA-4hvx-q2w4-f48v"}],"affected":[{"package":{"name":"chai-as-tokenized","ecosystem":"npm","purl":"pkg:npm/chai-as-tokenized"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"}]}],"versions":["7.2.3"],"database_specific":{"cwes":[{"description":"The product contains code that appears to be malicious in nature.","cweId":"CWE-506","name":"Embedded Malicious Code"},{"description":"The product contains code that appears to be malicious in nature.","cweId":"CWE-506","name":"Embedded Malicious Code"}],"source":"https://github.com/ossf/malicious-packages/blob/main/osv/malicious/npm/chai-as-tokenized/MAL-2026-5902.json","indicators":{"package_integrity":[{"hashes":{"sha1":"4c64d6512b4b4d9949e47a7d9c815c4aa6cec7d3","sha512_sri":"sha512-qQbUdMoy5NuH9wMuxvFs6raZYv9aCQiFQGHMpdK+K5aCKaASuysJJrX+koLUj1RPWW2n6lzHt+HVhWMhKT4H6A=="},"filename":"chai-as-tokenized-7.2.3.tgz"}],"evidence_files":[{"tlsh":"f111008d61fc200c056512e6b22f18116022e4273d4ad4e47adc83470f9627fbd536df","sha256":"2a41c6b7c5e256d70f884c613c6412ef73d86f8cd8a65afe6afb64fabaf4e022","path":"lib/initializeCaller.js"},{"tlsh":"b6019c60ce788e2300ed25825c2a064376658c135928fc1d32db512c0f9d5ff15bf21e","sha256":"4d8216a654a4425808841d28009533a48a290c4b259186d287761d502af1ee06","path":"package.json"},{"tlsh":"0f318545b5f21259126d98c4f6b4a5263cdf9437331b76b1cded93952bce2080032bc7","sha256":"1f51184c197102444a2c8a23e4a8e54a6479750420512922fcb5d5f795c33911","path":"index.js"}]}}}],"schema_version":"1.7.5","credits":[{"name":"Amazon Inspector","contact":["inspector-research@amazon.com"],"type":"FINDER"}]}