cookie-parser-legacynpm
Malicious code in cookie-parser-legacy (npm) Remove it immediately and rotate any exposed credentials.
What this malware does
Package name and README impersonate the well-known cookie-parser Express middleware. The source is a near-verbatim copy of cookie-parser, except the legitimate cookie-signature dependency has been replaced with an unknown package moustick pinned to the mutable latest tag (package.json: "moustick": "latest"). index.js requires moustick as signature and invokes signature.unsign(str.slice(2), secrets[i]) at request time on user-supplied cookie values, executing whatever code moustick currently publishes against installer-side cookie secrets and signed values. index.js additionally imports execSync from child_process at the top of the file with no reference anywhere in the cookie-parsing logic — an unusual staging artifact for a pure parsing module. The combination of name-impersonation of a top-tier middleware, silent substitution of a security-critical dependency, and pinning that substitute to a mutable tag means any installer who picks this up thinking it is cookie-parser will resolve and execute arbitrary third-party code controlled by the moustick publisher on every install.
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.
Malicious versions
Indicators of compromise (SHA-256)
Detection & response playbook
TyposquatFind it
Scan your lockfiles (package-lock.json, pnpm-lock.yaml, yarn.lock, requirements.txt, poetry.lock, etc.) and build artifacts for cookie-parser-legacy (4 malicious versions). O3 Security's supply-chain scanner checks every dependency against known-malicious package intelligence at install time and in CI, flagging cookie-parser-legacy across your stack and pipelines.
If you installed it — respond
cookie-parser-legacy is a typosquat — you almost certainly intended a legitimately-named package. Remove cookie-parser-legacy, install the correct package, and rotate any secrets exposed during the install since post-install scripts may have already run.
Did it already run?
If cookie-parser-legacy was ever installed, its post-install/runtime payload may have already executed. O3's L7 egress monitoring and runtime eBPF sensors detect the credential exfiltration or command-and-control callback after install and block the malicious outbound channel, so you catch and contain the actual compromise — not just the presence of the package.
How O3 protects you
O3 blocks cookie-parser-legacy before install through its supply-chain scanner, and if it has already run, detects and severs the exfiltration or C2 callback at runtime through L7 egress monitoring and eBPF.
Frequently asked questions
Campaign
References
Credits
- Amazon Inspector · finder
Detect & block this
O3 blocks cookie-parser-legacy-class packages before install and in CI — and if it already ran, its runtime egress monitoring catches the malicious outbound activity and severs the channel.