Re:Understand filesystem takeover vulnerabilities in NPM Jav...
by tomxor on Wednesday January 08, 2020 @07:47AM
(#21990886)
Yes exactly, which is why npm's default root prefix is a poor choice, see my other comment for a slightly safer alternative.
[ Parent
| on HN ]
Re:Understand filesystem takeover vulnerabilities in NPM Jav...
by inimino on Wednesday January 08, 2020 @09:11AM
(#21991538)
No, it's not. If you want to install a package like babel or webpack, or npm itself, and you want it to install manpages and commands like any real Unix program, you want it in /usr/local, and this is exactly what /usr/local is for.
These are the usecases that -g is for, and that's the only thing it's for: utilities that you want to add to your system, not mere runtime JS dependencies. NPM has this feature because in the beginning people (including me) wanted it to be more than just a manager for JS files under a build directory, because we were using it to build shared useful utilities, not just runtime dependencies.
This is a problem that has played out again and again with every programming language that has its own package installer, because setting the boundaries and interacting with the host system correctly while satisfying everyone's needs is challenging.
Re:Understand filesystem takeover vulnerabilities in NPM Jav...
by tomxor on Wednesday January 08, 2020 @09:26PM
(#21997978)
Using ~/.local gives you all those things without giving root access, there is no good reason to stick everything in /usr/local especially with something like npm which is wide open for anyone to publish anything instantly.
Re:Understand filesystem takeover vulnerabilities in NPM Jav...
by inimino on Friday January 10, 2020 @12:27AM
(#22008539)
Yes, and then the question is, should you be putting programs you don't trust at all in your PATH?
Re:Understand filesystem takeover vulnerabilities in NPM Jav...
by tomxor on Friday January 10, 2020 @04:52PM
(#22015996)
Yes, if i trust them enough to add and not replace binaries.
Re:Understand filesystem takeover vulnerabilities in NPM Jav...
by inimino on Sunday January 12, 2020 @10:25PM
(#22031579)
But once you run any of those binaries, it's free to replace any of your other (non-root-owned) binaries in `~/.local`. So the trust you're talking about seems to be a preference, but I don't think there's any particularly plausible threat model that makes one of these safer than the other.