npm

The mailparser and getcookies npm Supply Chain Attack

Updated 5 Oct 2026 · Incident date 12 Apr 2018

mailparser 2.2.1, 2.2.2 and 2.2.3 on npm added a dependency leading to the getcookies backdoor, which let any visitor send commands, in April 2018.

npm found the chain and removed all of it the same day. The mailparser versions never called the new package.

What happened

An attacker hid a remote code execution backdoor in a chain of npm packages and added the chain to mailparser.

  • The chain was mailparser to http-fetch-cookies to express-cookies to getcookies.
  • The last package read HTTP request headers for a pattern of the form gCOMMANDhDATAi.
  • The control code 0xfffe reset a buffer.
  • The control code 0xfffa ran the buffered code with vm.runInThisContext.
  • An Express app that used the module directly can run attacker code from a web request.

npm got the first report at 5:23 AM PDT. It removed the three malicious packages at 7:01 AM and the three mailparser versions at 7:26 AM.

Affected versions

  • mailparser 2.2.1, 2.2.2, 2.2.3: removed from npm. Version 2.2.0 is clean.
  • http-fetch-cookies, express-cookies and getcookies: all versions removed.
  • The mailparser versions did not use the module. Mailparser users were not exposed by the backdoor itself.

Indicators of compromise

  • Any of the packages getcookies, express-cookies or http-fetch-cookies in node_modules or in a lock file.
  • A mailparser entry at 2.2.1, 2.2.2 or 2.2.3 in a lock file.
  • A vm.runInThisContext call in a package that has no reason to run code.
  • The publisher account dustin87.

How to check

List the malicious packages in your dependency tree and check the mailparser version. An empty result for the first three packages means the chain is not installed.

npm ls getcookies express-cookies http-fetch-cookies mailparser
grep -nE "getcookies|express-cookies|http-fetch-cookies" package-lock.json

What to do now

  1. Move mailparser to 2.2.0 or a later release that does not contain the chain.
  2. Delete node_modules and install again from a clean lock file.
  3. Stop use of getcookies, express-cookies and http-fetch-cookies.
  4. If an Express app used the packages directly, treat the server as exposed. Review the logs for odd request headers and rotate secrets.

What Vigilance would show

These examples show an install hold and the corresponding owner report.

Example install message

Vigilance blocked `mailparser` 2.2.1. This version is too new or changed in a way Vigilance must check first.

Example owner report

Bad update

mailparser 2.2.1

The email reader pulled in a hidden helper that let any visitor send commands and have them run.

See what to do now.

No security team? See who reads the alert.

Frequently asked questions

Which mailparser versions had the getcookies backdoor?

Versions 2.2.1, 2.2.2 and 2.2.3. They depended on http-fetch-cookies, which depended on express-cookies and then getcookies.

Was mailparser itself exploitable?

According to the npm report, the mailparser versions did not use the module in any way. Apps that used the malicious packages directly were the real risk.

How do I check for getcookies in my project?

Run npm ls getcookies express-cookies http-fetch-cookies mailparser and search package-lock.json for the same names.

Sources

  1. blog.npmjs.org/post/173526807575/reported-malicious-module-getcookies
  2. bleepingcomputer.com/news/security/somebody-tried-to-hide-a-backdoor-in-a-popular-javascript-npm-package/
  3. theregister.com/2018/05/04/cookie_compromise_caper_caught_and_crumbled/

Send this page to the person who looks after AI at your company.

Email it

More supply chain attacks

All 172 attacks in the library · npm supply chain attacks · How to prevent supply chain attacks

Check the next update before you install it

Vigilance compares the version you trust with the new one. It names the one file that gained a power the old version did not have.

Start the free 14-day trialBrowse the attack library