How easy is it for a developer to "sandbox" a program?

kristaps.bsd.lv

50 points by zdw 5 days ago


Defletter - 13 hours ago

If I may just take this opportunity to moan about particular sandboxes: I use the flatpak version of Discord because of the promise of sandboxing in part because I hope it'll mitigate some of the telemetry happening but I doubt it does, but I digress. It is so annoying that anytime I want to drag a file into Discord, I first need to copy it to ~/Downloads. I'M GIVING YOU TO THE FILE, TAKE IT.

I feel this same way about Android permissions too. I don't feel like "this button opens the camera and gives me the photo you take with it" and "I can access whatever the camera is seeing at this moment" should be the same permission. Hell, the former wouldn't even need to be a permission. Ditto with photos. Why do I need to give WhatsApp access to my photos to include a picture in my message? Just allow the button to open an Android OS element that it has no access to, then I can select a photo/photos through it, and then Android gives WhatsApp those photos. And if you take a photo from WhatsApp and want to save it, that should be just as easy, like downloading a file from a browser.

I get the sense that most sandboxing/permission systems are just flags on specific API calls: you want to access a folder? well you need an fs permission for that! But don't worry, once you have permission, it's carte blanche! The only pipe-based sandboxing system I've encountered thus far is the share feature, but this is often so limited.

simonw - 15 hours ago

The situation on macOS is so frustrating. sandbox-exec / seatbelt has been marked as deprecated for nearly a decade now (since macOS Sierra in 2016) but it's still what everyone uses - here's OpenAI using it for their new Codex CLI: https://github.com/openai/codex/issues/215

Maybe the new "containers" stuff in macOS 26 is going to be a good replacement for that? It seems like that's a different solution though.

All I want is an easy, documented, supported way to run a binary on my computer and say "it can only access these files, use this much RAM and it's not allowed to make any outbound network requests". It always surprises me how hard this is!

PhilippGille - 14 hours ago

Another comment already mentioned Chromium. In a similar ballbark I'd mention Deno for running TypeScript/JavaScript in a Sandbox that you have to give explicit permission for filesystem and network access [1].

And WebAssembly should probably be mentioned as well [2].

[1] https://docs.deno.com/runtime/fundamentals/security/

[2] There are different runtimes, this is one of them: https://docs.wasmtime.dev/security.html

godelski - 14 hours ago

Given the first line I think the OP should check out systemd. You can run something as a service and sandbox it that way or go to nspawn to do "chroot on steroids" or upgrade to a full virtual machine

petermcneeley - 15 hours ago

For obvious reasons chromium has pretty extensive sandboxing. You can read the source right here: https://source.chromium.org/chromium/chromium/src/+/main:con...

hdjrudni - 15 hours ago

I'm interested in this for an upcoming project, but complexity of setup doesn't seem like a great way to compare these projects. What I need to know is (a) can I run completely untrusted code in these sandboxes? (b) Which let me disable network access, file system access, and limit CPU and RAM usage? i.e. feature set.

The set up might be a pain in the butt, but I'm assuming I only have to do it once and then I can stuff arbitrary programs into it.

user_7832 - 14 hours ago

Tangential: Are there any good methods for windows/windows software? Hyper V is fine for small code, but if you want to install a program everytime it gets old really fast. I wouldn't want to trust random files off the internet either.

smartaz42 - 12 hours ago

I haven't personally used it but cosmopolitan claims to provide a simple and portable sandboxing capability

nesarkvechnep - 13 hours ago

Capsicum is the most sophisticated of them all. It’s pretty great what you can do with it, coupled with Casper.

jbverschoor - 14 hours ago

Doesn't really matter as long as:

1) Developers flag "every permission"

2) No checks are happening at the distribution level

ZeroConcerns - 15 hours ago

While interesting, the failure to distinguish between cooperative and unmodified programs here sort-of weakens the comparison.

I mean, the OpenBSD APIs are great and all, but most developers are not going to be aware of these, nor deploying to a platform that supports these in the first place.

And yes, kernel-mode supervisors, when available, suffer from inscrutable configurations, so it's clear a middle ground would be nice (especially one that also applies to the W-environment), but it's not clear anyone is particularly invested in this?

charcircuit - 13 hours ago

Android handles sandboxing for programs automatically. If programmers have to explicitly write code to sandbox things, most never will.

beefnugs - 11 hours ago

No mentions of "Syd" anyone use this yet?

oblio - 12 hours ago

Maybe someone knows. There used to be a sort of Windows sandboxing or at least monitoring app named after a god, maybe 15,+ years ago. It could monitor what an app was doing at low level and I think it could even sandbox it.

Does anyone know its name?