{"id":"MAL-2026-10047","summary":"Malicious code in chai-as-staged (npm)","details":"\n---\n_-= Per source details. Do not edit below this line.=-_\n\n## Source: amazon-inspector (84d908f9158abcdd631b569f812b06cb59a1788f2435dd05a47fd39021d60a49)\nPackage name impersonates the popular `chai-as-promised` testing library and the README is copied from `pino`. The advertised usage `chai.use(chaiAsStaged)` triggers a detached `node` child process that runs `lib/initializeCaller.js`. That file hides its C2 endpoint and a custom HTTP header name/value as base64 strings stored under decoy names (`DEV_API_KEY`, `DEV_SECRET_KEY`, `DEV_SECRET_VALUE`) inside a fake local `process` object; at runtime it base64-decodes the URL to `https://amethyst-lorrin-26.tiiny.site/index.json`, fetches it with the obfuscated header, extracts the `.cookie` field from the JSON response, and executes the returned JavaScript via `new Function.constructor('require', response)(require)` in a retry loop. Attacker-controlled code is therefore executed on the installer's machine with full `require` access whenever the library is used as documented. The combination of name/README impersonation, base64-obfuscated C2 on an anonymous static-hosting host, and dynamic code construction with `require` removes any benign interpretation.\n","modified":"2026-07-09T16:31:53.189754413Z","published":"2026-07-09T15:34:00Z","database_specific":{"malicious-packages-origins":[{"modified_time":"2026-07-09T15:34:00Z","sha256":"84d908f9158abcdd631b569f812b06cb59a1788f2435dd05a47fd39021d60a49","source":"amazon-inspector","versions":["6.0.4"],"id":"IN-MAL-2026-009139","import_time":"2026-07-09T16:20:44.65683469Z"}]},"references":[{"type":"PACKAGE","url":"https://www.npmjs.com/package/chai-as-staged/v/6.0.4"}],"affected":[{"package":{"name":"chai-as-staged","ecosystem":"npm","purl":"pkg:npm/chai-as-staged"},"versions":["6.0.4"],"database_specific":{"indicators":{"evidence_files":[{"path":"index.js","sha256":"1f51184c197102444a2c8a23e4a8e54a6479750420512922fcb5d5f795c33911","tlsh":"0f318545b5f21259126d98c4f6b4a5263cdf9437331b76b1cded93952bce2080032bc7"},{"path":"lib/initializeCaller.js","sha256":"2a41c6b7c5e256d70f884c613c6412ef73d86f8cd8a65afe6afb64fabaf4e022","tlsh":"f111008d61fc200c056512e6b22f18116022e4273d4ad4e47adc83470f9627fbd536df"}],"package_integrity":[{"filename":"chai-as-staged-6.0.4.tgz","hashes":{"sha512_sri":"sha512-tFDk65d/L3uLXuRyFZPvxCOHurxZX4gkrlx4FGpxaq+hlP69Q9ZDS9HluwjTSCPnXSWMmNbukr1JEquw8zWwlw==","sha1":"3ef5b4709cfd792b1345ebe3ae22a956f58fe7ff"}}]},"cwes":[{"cweId":"CWE-506","description":"The product contains code that appears to be malicious in nature.","name":"Embedded Malicious Code"}],"source":"https://github.com/ossf/malicious-packages/blob/main/osv/malicious/npm/chai-as-staged/MAL-2026-10047.json"}}],"schema_version":"1.7.5","credits":[{"name":"Amazon Inspector","contact":["inspector-research@amazon.com"],"type":"FINDER"}]}