Comment Do your research (Score 2) 11
This sort of attack is inevitable when you have open-access software repositories. If anybody can upload a package, that implies any bad guy can upload a package. So:
- Ask yourself if you really need a package for this, or is it simple or straightforward enough you can code it yourself and avoid the dependency and the associated supply-chain risks.
- Do your research. Don't just grab the first package that looks like it fits your needs. Review all of the results, then look at who published them and look them up on the web. Look at their web site. Look at what other packages they've published. Look at how active they are aside from the package you're looking at. Toss any that have red flags like no history aside from this package.
- Validate your packages. Authors often sign packages. If they do, get their keys and enable validation so you only accept packages signed by the author you know. That way if a package gets hijacked it'll fail the signature check.