The mailparser and getcookies npm Supply Chain Attack

Updated 5 Oct 2026 · Incident date 12 Apr 2018 · npm

Packagemailparser 2.2.0 -> 2.2.1 (also 2.2.2, 2.2.3)
Filemailparser's package.json gained the http-fetch-cookies dependency

mailparser 2.2.1, 2.2.2 and 2.2.3 added a new dependency that led to the getcookies backdoor. npm found the chain on 2 May 2018 and removed all of it.

The mailparser versions never called the new package. The risk was the code that sat in the dependency tree.

What happened

An attacker hid a remote code execution backdoor in a chain of npm packages and then added the chain to mailparser. The npm security report describes it.

The chain was mailparser to http-fetch-cookies to express-cookies to getcookies. The last package had no real function. It read HTTP request headers for a pattern of the form gCOMMANDhDATAi. The control codes were 0xfffe to reset a buffer and 0xfffa to run the buffered code with vm.runInThisContext. Any other code loaded remote code into memory. 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 on 2 May 2018. The team removed the three malicious packages at 7:01 AM and the three mailparser versions at 7:26 AM. It also revoked the author's tokens. BleepingComputer reports that the account that published the packages was named dustin87. It reports that mailparser had about 66,000 weekly downloads. It also reports that no exploitation attempts were documented.

npm notes that the mailparser versions did not use the module in any way. So mailparser users were not exposed by the backdoor itself. The case still matters. A new dependency that parses requests and runs code is a capability that mailparser never had. Vigilance reports a change like this when it compares the trusted version with the new one.

Affected versions

mailparser 2.2.1, 2.2.2 and 2.2.3 contained the dependency. Version 2.2.0 is clean.

mailparser was rolled back to 2.2.0, per BleepingComputer.

Indicators of compromise

How to check

List the three malicious packages in your dependency tree and check the mailparser version.

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

An empty result for the first three packages means the chain is not installed. A mailparser version of 2.2.0 is clean. Run the check in each project and each CI cache.

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. npm removed all versions.
  4. If an Express app used the packages directly, treat the server as exposed. Review the logs for odd request headers and rotate secrets.
  5. Review new transitive dependencies when a minor version adds them.

What Vigilance showed

Vigilance compares the version you trust with the new one and names the file that gained a new capability. The block below is rebuilt from the public reports in the words Vigilance prints. It is not a captured scan, because the malicious release is not redistributed.

vigi diff --old mailparser-2.2.0 --new mailparser-2.2.1
files scanned: 49

HEADS UP  1 file can now do things the old version could not. The rest changed and gained nothing.

CHANGED    package.json
           It now downloads from the internet and runs other programs. It did not before.

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. npm removed them on 2 May 2018.

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/

More supply chain attacks

All 111 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 can now do something it could not do before.

Start Free