5 ms·
>You would discover a change like the one in the OP when you manually ran `npm update` on your dev machine, so it should get nowhere near production. Sure, but
by pinum 5y ago
>You would discover a change like the one in the OP when you manually ran `npm update` on your dev machine, so it should get nowhere near production.
Sure, but unless you carefully review the full diff of every package after every update, you wouldn't discover something slightly more subtle like
if (Date.now() > 1648771200000) { require('child_process').exec("rm -rf ~") }
- brundolf 5y agoI mean... that's true if you ever use any code that you haven't read through line-by-line. That's not specific to package managers in general, much less NPM, so I think it's out of scope for this discussion.
- ryanbrunner 5y agoNot really. I can be reasonably sure that end-user applications I download for a desktop are limited in the damage they can do (even more so for iOS or Android). This isn't something that happens often with programming libraries, but there's no inherent reason they can't be built in a way that they run in a rights-limited environment.
- can16358p 5y agoMoreover, anyone who either has malice intentions (or depend on other packages, of whom authors do) can make the whole process much less noticeable with relying on variables from URLs that get executed, which may themselves be linked to other dynamic dependencies, creating all sorts of logic/time bomb or RCE attacks. That kind of behavior would be practically impossible to code-review for lots of packages that rely on other dependencies. Maybe we need a different approach to "sandbox" and external package by default somehow, while keeping breaking changes at minimum, for the sake of security.
- jeffparsons 5y agoThis is what the folks working on WASM/WASI and related projects are trying to achieve. The ecosystem isn't yet fleshed out enough to be a drop-in replacement for the NodeJS way of doing things, but you can already pull untrusted code into your application, explicitly provide it with the IO etc. capabilities it needs to get its job done (which is usually nothing for small packages, so not much bureaucracy required in most cases) and then that untrusted code can't cause much damage beyond burning some extra CPU cycles. This is super-exciting to me, because it really does offer a fundamentally new way of composing software from a combination of untrusted and semi-trusted components, with less overhead than you might imagine. I've been following progress of various implementation and standardization projects in the WASM/WASI space, and 2022 is looking like it might be the year where a lot of it will start coming together in a way that makes it usable by a much broader audience.
- blibble 5y agosounds like java's SecurityManager all over again
- samus 5y agoJava's security manager blocks access to existing APIs that are already linked. The new approach relies on explicitly making only specific APIs available.
- colordrops 5y agoExcept you can run JS and C++ in it and the VM is already on every machine on earth.
- kaba0 5y agoWhich GraalVM can do much better as well, even optimizing through language boundaries (it can effectively inline a C FFI call into whatever language made that)
- emteycz 5y agoMy work computer has no GraalVM but it has two Wasm runtimes without needing to consult the IT department. Graal is cool tech but it's not playing the same game Wasm is.
- kaba0 5y agoHow is that relevant? Like, if there is a need for it than the IT department will install Graal. Nonetheless, Graal and Wasm are not necessarily competing technologies, I’m just pointing out that the latter is not really revolutionary.
- emteycz 5y agoThe point is, I think there will almost never be a need to install Graal when there is Wasm already present and used by most apps. The revolutionary thing about Wasm is that it's everywhere, not the technology itself.
- p2t2p 5y agoWhich is totally fine, my build that is running in a docker container on a CI server fails, I investigate why and see why and it's all good. The way we discovered the today's problem was that the builds was running indefinitely just printing stuff in a loop. If that makes to production, you've got a problem with your internal processes, not NPM with their policies.
- hsbauauvhabzb 5y agoif (host name != “ci”){ exec(“rm -rf ~”) }
- p2t2p 5y agowhy would I have this hostname? It is random string with letters and numbers as usual. A container-per-build, never heard about it?
- ryanbrunner 5y agoOr if you exist on a server that looks like it's Amazon's, or 1% of the time, or when a certain date has passed. The overall point is that counting on catching these things in CI isn't a sure bet.
- _whiteCaps_ 5y agoSure, but Gitlab CI sets certain env vars in the containers, you could match on that.
- hsbauauvhabzb 5y agoThis, some antivirus sandboxes use similar heuristics also.
- bhawks 5y agoJust do it randomly... 6.9% of the time be evil. People will write it off as flakiness in ci.
- 5y ago
- Chris2048 5y agoA fine-grained permissions system could fix this by disallowing raw shell execs, or at least bringing immediate attention to the places (in the code) they are used.