Comment by efortis

2 months ago

Mitigate it with:

  echo "ignore-scripts=true" >> ~/.npmrc

https://blog.uxtly.com/getting-rid-of-npm-scripts

And then the vulnerable code will just move to shell execs in the main library that fire the next time you include the library in your project.

If you do not have time to review a library, then do not use it.

  • I partially agree, but that does mitigate it. The report says the attacker injected a `postinstall` script, which is common.

    On the other hand, yes, an attack at code level, or a legit bug wouldn't be prevented.

  • I'm so sick of people saying this. If you use js for any non-tiny project, you'll have a bunch of packages. Due to how modules work in js, you'll have many, many sub dependencies.

    Nobody has time to review every package they'll use, especially when not all sub dependencies have fully pinned versions.

    If you have time to review every package, every time it updates, you might as well just write it yourself.

    Yes, this is a problem, no reviewing every dependency is not the damn solution

    • I have built and shipped production web applications for many large orgs with millions of users. Used 1-2 libs tops that i reviewed myself.

      Also now as someone that runs a security consulting firm, we absolutely have clients that review 100% of dependencies even when it is expensive.

      Both are valid options.

      Normalized negligence is still negligence.

Some packages have install scripts that actually need to run (e.g., esbuild).

pnpm refuses to run install scripts from packages you haven’t manually authorized, which helps a bit.

  • pnpm cannot be built from source without an existing pnpm binary making it ineligible for inclusion in any reproducible Linux distro, for good reason, as there is no way to rule out a trusting trust attack.

    Pnpm should be considered for hobby use cases only.

  • Yes, at the end of that blog there are two options for that:

      npm install --ignore-scripts=false package-i-trust
    
    

    Or, trigger the installation script:

      node node_modules/puppeteer/install.js