7 ms·
It seems to me like one low hanging fruit to make a lot of these kinds of exploits significantly more difficult is protection at a language level about which li
by HALtheWise 5y ago
It seems to me like one low hanging fruit to make a lot of these kinds of exploits significantly more difficult is protection at a language level about which libraries are allowed to make outgoing HTTP requests or access the file system. It would be great if I could mark in my requirements.txt that a specific dependency should not be allowed to access the file system or network, and have that transitively apply to everything it calls or eval()'s. Of course, it would still be possible to make malware that exfiltrates data through other channels, but it would be a lot harder.
I am not aware of any languages or ecosystems that do this, so maybe there's some reason this won't work that I'm not thinking of.
- parhamn 5y agoI was wondering earlier how useful deno's all-or-nothing policies would actually be in the real world. It seems like rules like this (no dep network requests, intranet only, only these ips) are much more useful than "never talk to the web". For python this probably wont ever be possible given the way the import system works and the patching packages can do.
- tadfisher 5y agoPortmod[0] is a package manager for game modifications (currently Morrowind and Doom), and it runs sandboxed Python scripts to install individual packages. So I think this is possible, but it's not a built-in feature of the runtime as is the case for deno. [0]: https://gitlab.com/portmod/portmod https://gitlab.com/portmod/portmod
- hortense 5y agoThis can be done with capability-based operating system, though it requires running the libraries you want to isolate in a separate process. On a capability-based OS you whitelist the things a given process can do. For instance, you can give a process the capability to read a given directory and write to a different directory, or give the capability to send http traffic to a specific URL. If you don't explicitly give those capabilities, the process can't do anything.
- delosrogers 5y agoIf I’m not mistaken I think that some languages with managed effects allow you to do this through types. For example, in Elm HTTP requests have the type of Cmd Msg and the only way to actually have the IO get executed is to pass that Cmd Msg to the runtime through the update function. This means you can easily get visibility, enforced by the type system, into what your dependencies do and restrict dependencies from making http requests or doing other effects.
- landonxjames 5y agoDeno (a Node-like runtime by the original author of Node) has a security model kind of like this [0]. Its unfortunately not as granular as I think it should be (only operates on the module level and not individual dependencies), but its a start. [0] https://deno.land/manual/getting_started/permissions https://deno.land/manual/getting_started/permissions
- bredren 5y agoRyan Dahl, (above mentioned creator of Deno), gave his second podcast interview ever this spring, it went live June 8th. [1] It covers a lot of terrain including the connectivity permissions control. I recommend it as an easy way to learn about Deno and how it is different from Node as it is today. Node seems to have evolved to handle some of what Deno set out to do at the start. It is worth hearing from Dahl why Deno is still relevant and for what use cases. Dahl speaks without ego and addresses interesting topics like the company built around Deno and monetization plans. [1] https://changelog.com/podcast/443 https://changelog.com/podcast/443
- helsinki 5y agoThis is a great idea, but I'm not sure how it could be implemented without cgroups, which are a pain, especially when you don't have root access.
- staticassertion 5y agoI started building this at one point. Basically there's an accompanying manifest.toml that specifies permissions for the packages with their checksums, and then it can traverse the dependency graph finding each manifest.toml. It also generated a manifest.lock so if manifests changed you would know about it. Then once it built up the sandbox it would execute the build. If no dependencies require networking, for example, it gets no networking, etc. I stopped working on it because I didn't have time, and it obviously relied on everyone doing the work of writing a manifest.toml and using my tool, plus it only supported rust and crates.io TBH it seems really easy to solve this problem, it's very well worn territory - Browser extensions have been doing the same thing for decades. Similarly, why can I upload a package with a near-0 string distance to another package? That'd help a massive amount against typosquatting. No one wants to implement it who also implements package managers I guess.
- dhosek 5y agoI've been thinking about this a lot as I consider the scripting language for finl.¹ I had considered an embedded python, but ended up deciding it was too much of a security risk, since, without writing my own python interpreter (something I don't want to do), sandboxing seems to be impossible. Deno is a real possibility or else forking Boa which is a pure Rust implementation of JS. 1. One thing I absolutely do not want to do is replicate the unholy mess that's the TeX macro system. There will be simple macro definitions possible, but I don't plan on making them Turing complete or having the complex expansion rules of TeX.
- cesarb 5y agoWhat you want sounds like the way Java sandboxing worked (commonly seen with Java applets). The privileged classes which do the lower-level operations (outgoing network requests, filesystem access, and so on) ask the Java security code to check whether the calling code has permission to do these operations, and that Java security code throws an exception when they're not allowed.
- geofft 5y agoYes, and also, this is an extraordinarily complex design to implement and get right. Java more or less failed in contexts where it was expected to actually enforce those boundaries reliably - untrusted applets on the web. It's working great in cases where the entire Java runtime and all libraries are at the same trust level and sandboxing/access control measures, if any, are applied outside the whole process - web servers, unsandboxed desktop applications like Bazel or Minecraft, Android applications, etc. Security vulnerabilities in Java-for-running-untrusted-applets happened all the time; security vulnerabilities that require you to update the JRE on your backend web servers are much rarer. If you make a security boundary, people are going to rely on it / trust it, and if people rely on it, attackers are going to attack it for real. Making attacks harder isn't enough; some attacker will just figure it out, because there's an incentive for them to do so. It is often safer in practice not to set up the boundary at all so that people don't rely on it.
- draegtun 5y ago>> I am not aware of any languages or ecosystems that do this... Rebol was designed with such a feature - http://www.rebol.com/docs/words/wsecure.html http://www.rebol.com/docs/words/wsecure.html