One can protect from these kinds of vulnerabilities by setting ignore-scripts to true as default:
npm config set ignore-scripts true
yarn config set ignore-scripts true
https://blog.npmjs.org/post/141702881055/package-install-scr...