-
Notifications
You must be signed in to change notification settings - Fork 85
Mitigating Postinstall Attacks like the Shai‐Hulud Worm
Notes:
-
Shai-Hulud worm reversinglabs.com, socket.dev
-
npm ciandyarn install --frozen-lockfileare generally safe. -
npm install --ignore-scriptsis generally safe. -
npm config ignore-scripts truewill protectnpm installin general, but impedes local script running, so consider using other means. -
yarnandyarn installare not safe if you have introduced any new dependencies topackage.jsonanywhere in your project, and those new dependencies can force other dependencies to upgrade. -
The LavaMoat allow-scripts tool significantly limits attackers’ ability to execute arbitrary code with all of your user rights when you use
npm installoryarn. The workflow for setting up LavaMoat includes npm configuration above and a mechanism to allow specific scripts. -
If you publish npm packages, make sure you have MFA set up https://docs.npmjs.com/configuring-two-factor-authentication This does not prevent an attacker from running arbitrary code and moving laterally throughout your system and connected devices, but does prevent them from using your credentials to publish packages and spread a worm.
-
pnpmfrom version X is the only package manager that does not run postinstall scripts by default. CITATION NEEDED -
Do not use
yarnversion 3. Check withyarn --version. Note that theyarnversion may depend onpackageManagerin yourpackage.json. Add"packageManager": "yarn@4.9.1", for example. https://github.com/yarnpkg/berry/issues/6258 -
ignore-scriptsin Yarn configuration (.yarnrc) https://classic.yarnpkg.com/lang/en/docs/cli/config/ DETAILS NEEDED -
enableScripts: falsein.yarnrc.ymlCITATION NEEDED