3 ms·
I tried building something like this for rust, in order to execute closures as a separate process[0]. I could probably automate it for a struct with a macros s
by staticassertion 8y ago
I tried building something like this for rust, in order to execute closures as a separate process[0].
I could probably automate it for a struct with a macros so that the API was autosandboxed. Also, it was purely an experiment and is not particularly safe - secrets in the "broker" process would leak to the client, for example. I had plans to deal with at least some of these issues using a build.rs to generate a separate binary that could be exec'd but I stopped caring.
I wonder how this sandboxapi gets around that?
The reason I didn't bother was because I found that constructing the sandbox was the hard part, not executing the code in it - how do you detect what the code needs to do in the sandbox? You end up too tight or too loose.
Also, performance is miserable if you have to fork/exec every single time. So you may be tempted to cache the process across executions but that comes with its own pains. Again, curious how this is dealt with in sandboxapi.
Personally, I want to see sandboxing support at a language level. I imagine a language, perhaps like Pony, which has isolated units of execution that connect via some form of RPC/message passing. With a type system that "taints" types based on actions, basically a capability type that propagates upwards, you could generate seccomp filters for every unit of execution. Pony seems like it's actually not far from this, from what I could tell.
Sandboxing in a language like this is a matter of moving the execution unit out of process, which shouldn't be that hard.
[0] https://github.com/insanitybit/sandbox https://github.com/insanitybit/sandbox
- jagger11 8y agoHi, one of the authors here. The sandboxed library is indeed exec'd (it's a separate binary), so the only "secrets" that leak into it, are those which are already there - compiled into the binary. As for fork/exec: the idea is to preserve the execution context as long as possible - if data leaks between sequences of library API calls are not a problem (e.g. because we just convert some data for internal use), then forking/execve is not necessary. The idea behind 'transactions' (as per Sandboxed API nomenclature) is just that. If potential data leaks between API calls might be a problem, then a fresh instance is spawned via fork (no execve is needed here though).
- staticassertion 8y agoHi, First off, thanks for the reply and congrats on the release. Separate binary makes sense - I wanted to get there myself but didn't have the patience. I'll have a look at the code to see how that works. Sounds like you've considered some of the areas I had concerns with already.