Tl;dr[EDIT 2018-07-16] The official ESLint post-mortem has been released. NPM already revoked all tokens at once so you probably don’t need to do this yourself.
A backdoor was introduced on eslint-scope (version 3.7.2) upon which ESLint depends.
It seems that the goal of this hack was to leak NPM tokens.
We advise you to take the following actions as soon as possible:
- Revoke all your NPM tokens at once
- Enable 2FA on your NPM account for all scopes
- Audit the NPM packages you own to ensure nobody published new versions without you knowing
- If you are running a private registry or a mirror, delete this package
- Ensure you don’t have eslint-scope version 3.7.2 on your computers
It shows that the said module was backdoored with the following script:
This script simply fetches the content of a pastebin document and eval it in the current Node.js process.
The pastebin document has already been unpublished, but thankfully someone copied it before:
This script looks up for a file named
.npmrc on the current user home. This is where NPM CLI stores the user token. This token is used to authenticate a user against the NPM registry.
.npmrc file is found, the script identifies the user token and leaks it through the referer in a GET request to web analytics servers.
It is still not clear how this backdoor made its way to eslint-scope yet but as of today, version 3.7.2 has been unpublished from the registry.
We highly recommend you revoke all your NPM tokens at once. An attacker could use them to publish malicious packages on your behalf or access your organization private packages.
If you did not do it yet, enable 2FA on your NPM account now.
Also, if you run a private registry or a mirror, you should immediately unpublish email@example.com.
Please ensure this version of the package is not installed anywhere on your system. Even if the attack payload was removed from pastebin, one could theoretically change that again and run any arbitrary script on your machines.