News for hackers. Stuff that matters.
Re:Deno Is a Browser for Code by paxys on Thursday May 28, 2020 @11:34PM (#23346029)
The key paragraph:

> The Deno CLI works like a browser, but for code. You import a URL in the code and Deno will go and fetch that code and cache it locally, just like a browser. Also, like a browser, your code runs in a sandbox, which has zero trust of the code you are running, irrespective of the source. You, the person invoking the code, get to tell that code what it can and can’t do, externally. Also, like a browser, code can ask you permission to do things, which you can choose to grant or deny.

The big problem with Deno is that permissions, once granted, apply to every imported URL. You cannot ask it to let one script access the file system, another access network and the rest of them run fully sandboxed. This makes it so that you either only import scripts you already fully trust (making the permission system useless) or don't allow any access (making the ecosystem useless).

Re:Deno Is a Browser for Code by Vinnl on Friday May 29, 2020 @06:44AM (#23348423)
To keep with the browser comparison: browsers have started to add tracking protection, and people are installing adblockers, because we've basically concluded that we don't want the websites we load to call out to arbitrary other websites, even if we do want them to call out to some.

That said, sounds like it's something they're thinking about:

> It is also hard to break down those permissions, to say “this code can do this, but this other code over here can’t” or when code prompts to escalate privileges where is that code coming from. Hopefully we can figure out an easy to use mechanism coupled with something that would be effective and performant at runtime to try to solve those challenges.

Re:Deno Is a Browser for Code by asiachick on Friday May 29, 2020 @08:29AM (#23349165)
Except it's not a browser which never has file access, db access etc.... A MITM download in the browser affects a few users. A MITM download in Deno effects all users.
Re:Deno Is a Browser for Code by Vinnl on Friday May 29, 2020 @08:56AM (#23349365)
Let me tell you about IndexedDB and the File System API :)

Jokes aside, though, doesn't the MITM only affect users who run the MITM'd script, just like in the browser it only affects users who visit a MITM'd site?

Re:Deno Is a Browser for Code by PudgePacket on Friday May 29, 2020 @11:04AM (#23350753)
... Just like every other software dependency system ever.
Re:Deno Is a Browser for Code by freeopinion on Friday May 29, 2020 @12:08AM (#23346177)
Would you please clarify what you are talking about? You grant permissions on a script by script basis. Your statement looks to me like the exact opposite of reality. What have I misunderstood?
Re:Deno Is a Browser for Code by csande17 on Friday May 29, 2020 @12:55AM (#23346393)
I think you and the parent are working under different definitions of "script".

Deno allows you to grant permissions per top-level invocation. So if you have one program that you run by typing `deno run passwordmanager.js` at the console, and another program that you run by typing `deno run downloadfiles.js`, you can give different permissions to each of those "scripts".

But within one program, you can't (easily) give different permissions to different dependencies. If downloadfiles.js imports both http.js and check-if-number-is-even.js, and it wants http.js to be able to access the network, it has to request the access-the-network permission globally. So check-if-number-is-even.js would also be able to access the network. The different "script" files that make up one program all have to have the same permissions.

(Sure, Deno might have other ways to sandbox parts of your program, but so does Node -- Deno's permissions improvements don't really help you in that case.)

Re:Deno Is a Browser for Code by saagarjha on Friday May 29, 2020 @03:35AM (#23347226)
As someone unfamiliar with the ecosystem as a whole, is this not an issue similar to any sort of library that you run “in process”? Like, if you’re writing a mobile app and you manage to obtain location access, the Facebook SDK that you link against gets the same thing too?
Re:Deno Is a Browser for Code by aboodman on Friday May 29, 2020 @06:29AM (#23348335)
Yes this is the common way computers work, but there's no reason to accept it. When today's process model was designed, there was no such thing as github or the internet. The idea of googling for a hunk of code and just pasting it into your app was ... not a thing on anyone's mind.

You might argue people are wrong to do that, but the fact is it's extremely popular. And if we redesign the security model, we can allow people to do it safely.

Imagine if leftpad.js had no privileges to anything, even if included in an application that has privileges to network, disk, etc.

Re:Deno Is a Browser for Code by jfkebwjsbx on Friday May 29, 2020 @07:33AM (#23348734)
The fact that something is popular in webdev does not make it right nor popular outside webdev.

In almost any other CS field you would be crazy to use non-vetted third-party code and depend on external service providers for your code to simply run.

I can only think of draconian DRM, which puts things in perspective...

Re:Deno Is a Browser for Code by aboodman on Friday May 29, 2020 @10:45PM (#23358024)
It's popular everywhere. The Go ecosystem, or Rust ecosystem, as an example is just as bad about this as the JS ecosystem. There is a difference, but it's a constant factor. Asymptotically, everyone is just pasting code they found on the internet into their app. Crazy, but true.

That's why a per-library sandbox model seems so beneficial.

Re:Deno Is a Browser for Code by erik_seaberg on Friday May 29, 2020 @11:00PM (#23358095)
Loading classes over the network and running them in a configurable sandbox is what originally excited me about Java, but exploits were found and it's hardly ever used now.
Re:Deno Is a Browser for Code by aboodman on Friday May 29, 2020 @11:17PM (#23358175)
I mean there will definitely be exploits.

It does still seem dramatically different to need to get an escape out of the js sandbox than to just be handed privileges by design.

Particularly if (in some glorious future) the js vm is written in a safe language, not C++.

Re:Deno Is a Browser for Code by jfkebwjsbx on Friday May 29, 2020 @07:38AM (#23348758)
The thing with the web is that vetting dependencies is (for the most part) very uncommon.

Some people are realizing it is not a good idea to download random code. So the solution proposed by Deno is to sandbox it and put a capabilities system into it, rather than create a culture of proper dependency management.

At least they are trying...

Re:Deno Is a Browser for Code by entha_saava on Friday May 29, 2020 @04:00AM (#23347448)
But since there is a VM anyways, It is fair to expect library sandboxing.
Re:Deno Is a Browser for Code by bigyikes on Friday May 29, 2020 @01:15AM (#23346484)
Could the solution just be to audit the permissions your dependencies require? Sure, it gets murkier with transitive deps like your http.js and number-is-even.js example, but I would argue that this scenario isn’t as dangerous as it seems because it adds an opportunity for the middle-man-dependency (http.js) to catch overreaching permissions.

With node, it is very opaque. With deno, as I see it, http.js can easily check the permissions for number-is-even.js, and you can easily check the permissions of http.js. It’s not perfect, but I think each link in the dependency chain is at least more easily auditable, even if it is not strictly more secure.

Re:Deno Is a Browser for Code by bkolobara on Friday May 29, 2020 @04:10AM (#23347506)
In my experience, auditable doesn't really matter. To have peace of mind you really need to be able to enforce that number-is-even.js will never do a http request.
Re:Deno Is a Browser for Code by bigyikes on Sunday May 31, 2020 @03:55AM (#23367996)
I would seek to automate this audit and enforce it with a commit hook or CI stage or something
Re:Deno Is a Browser for Code by hombre_fatal on Friday May 29, 2020 @06:55AM (#23348493)
Doesn't solve the problem, but you can at least provide a whitelist of domains and filesystem paths.

For example, if you only whitelisted --allow-net=api.example.com, it would be a lot more annoying for a rogue dependency to exfiltrate data.

Re:Deno Is a Browser for Code by chii on Thursday May 28, 2020 @11:54PM (#23346114)
> ask it to let one script access the file system, another access network and the rest of them run fully sandboxed.

this is actually quite a difficult problem to solve. You're balancing the security needs with usability.

Browsers have an advantage on this aspect, because they can make the assumption that the webpage does not require filesystem access.

i think fully sandboxed OS-esque security model is the only way this can work. Like on android, where each app sees only their own filesystem, and app-to-app interaction is done via a permission based system that the user has to approve.

Re:Deno Is a Browser for Code by aabbcc1241 on Friday May 29, 2020 @06:12AM (#23348234)
On android the apps has access to shared folders. For example my music player can scan and read files under /mnt/sdcard/Android/data/com.dropbox.android/files/

It maybe more isolated if it follows the nix file system model?

Re:Deno Is a Browser for Code by bryanrasmussen on Friday May 29, 2020 @12:11AM (#23346188)
They could have maybe looked at E for some inspiration on how to solve the problem http://erights.org/
Re:Deno Is a Browser for Code by half-kh-hacker on Friday May 29, 2020 @02:32AM (#23346865)

    const status = await Deno.permissions.revoke({ name: "run" });
    assert(status.state !== "granted")

    import * from "https://shady-site.com/this-file-cannot-run-processes.ts"
Re:Deno Is a Browser for Code by datalist on Friday May 29, 2020 @03:49AM (#23347345)
Though after that point even your own code cannot use that permission anymore.
Re:Deno Is a Browser for Code by martin-adams on Friday May 29, 2020 @05:43AM (#23348060)
It would be amazing if it had scoped permissions.
Re:Deno Is a Browser for Code by jxub on Friday May 29, 2020 @06:05AM (#23348187)
I think Ryan is aware of this as it has been raised in some ocasions already, but it might be too complicated or costly in dev time to have before a new version bump.