logoalt Hacker News

agentifyshyesterday at 11:09 PM4 repliesview on HN

yeah i mean this is a tough problem. unless you work for a government contractor where they have strict security policies, most devs are just going to run npm install without a second thought as there are a lot of packages.

i dont know what the solution here is other than stop using npm


Replies

josephgyesterday at 11:52 PM

> i dont know what the solution here is other than stop using npm

Personally I think we need to start adding capability based systems into our programming languages. Random code shouldn't have "ambient authority" to just do anything on my computer with the same privileges as me. Like, if a function has this signature:

    function add(a: int, b: int) -> int
Then it should only be able to read its input, and return any integer it wants. But it shouldn't get ambient authority to access anything else on my computer. No network access. No filesystem. Nothing.

Philosophically, I kind of think of it like function arguments and globals. If I call a function foo(someobj), then function foo is explicitly given access to someobj. And it also has access to any globals in my program. But we generally consider globals to be smelly. Passing data explicitly is better.

But the whole filesystem is essentially available as a global that any function, anywhere, can access. With full user permissions. I say no. I want languages where the filesystem itself (or a subset of it) can be passed as an argument. And if a function doesn't get passed a filesystem, it can't access a filesystem. If a function isn't passed a network socket, it can't just create one out of nothing.

I don't think it would be that onerous. The main function would get passed "the whole operating system" in a sense - like the filesystem and so on. And then it can pass files and sockets and whatnot to functions that need access to that stuff.

If we build something like that, we should be able to build something like npm but where you don't need to trust the developers of 3rd party software so much. The current system of trusting everyone with everything is insane.

show 2 replies
miroljubyesterday at 11:29 PM

The issue with npm is JS doesn't have a stdlib, so developers need to rely on npm and third party libs even for things stdlib provide in languages like Java, Python, Go, ...

show 3 replies
____tom____today at 8:44 AM

Developing in a container might mitigate a lot of issues. Harder to compromise your development machine.

I guess if you ship it you are still passing along contagion

irishcoffeeyesterday at 11:25 PM

> unless you work for a government contractor where they have strict security policies

... So you're saying there is a blueprint for mitigating this already, and it just isn't followed?

show 2 replies