This is really dangerous because you're bypassing your lock file and you're giving the author of that package the ability to change the code out from underneath you. The other thing was, obviously, they didn't revoke the NPM access of the employee here, which is a serious problem. So I would kind of advise everyone to audit their NPM access pretty regularly and have a checklist for when you're offboarding an employee so that you can make sure to not forget a step like removing their NPM access.
And finally, I would consider using a GitHub Action workflow so that you don't have to actually give developers access to NPM. Now, on the user side, you know, the most important lesson here is don't use packages that remotely load code and bypass your lock file. That your dependencies, you know, the only way you're going to find out that a package is doing something like this is if you actually look at the code of it. Obviously, that's a lot of work. But as much as you can, spend time looking at the code in your dependencies. Understand what your dependencies are doing. This is not just for security. This will make you a better programmer. You'll learn about, you know, different coding styles and techniques. And it's actually just a good idea in general to learn. But you'll also discover when you're using a low-quality dependency. And then the other option is you can just use a security tool that detects these types of risks. So not detect vulnerabilities, but actually detect supply chain risks and code quality issues like this one. And so general advice, also use fewer dependencies, pin your dependencies, avoid mutable references to dependencies that can change out from underneath you.
So there were, you know, some folks using a vulnerability scanning tool such as Snyk that weren't protected from this attack. Well over 12 hours after this package was compromised, these tools were still reporting that the package had no known security issues to, you know, all their customers. So if you rely on a vulnerability tool, you know, you have to be aware that they're also not going to protect you from this type of attack. And unfortunately, you know, this is, to me at least, I find this so frustrating because, you know, on the one hand, our tools are literally, you know, not detecting the attacks like this that we actually care about, these attacks that are affecting the ecosystem. And yet, despite that, they also are drowning us in alerts. I mean, they're flooding us with meaningless alerts all the time. You know, 60% of people have said that their, you know, the number of alerts, so alert fatigue is what it's called, has created friction between their, you know, developer teams and their security teams. And, you know, I'm sure we've all seen the NPM audit output where you install a package and you immediately see that it has, you know, a hundred-plus vulnerabilities, and then you just shrug and move on with your day. So it's so – I just personally find it really frustrating that we're – our tools are constantly yelling at us about security vulnerabilities, but yet they don't – they can't even detect the type of vulnerability we just discovered. And, you know, Danny Abramov, you know, kind of wrote this famous viral post a few years ago about how NPM audit was broken by design. I mean, he had some pretty harsh words about kind of the problems with NPM audit. He called it a stain on the entire NPM ecosystem and said it was completely broken. And, you know, while I might have chosen different words myself, I do think there are several problems with NPM audit.
Comments