zlacker

[parent] [thread] 5 comments
1. simonw+(OP)[view] [source] 2026-02-07 01:36:23
How do I sandbox CPython using OS features?

(Genuine question, I've been trying to find reliable, well documented, robust patterns for doing this for years! I need it across macOS and Linux and ideally Windows too. Preferably without having to run anything as root.)

replies(2): >>OutOfH+G7 >>nickps+ed
2. OutOfH+G7[view] [source] 2026-02-07 03:00:58
>>simonw+(OP)
Docker and other container runners allow it. https://containers.dev/ allows it too.

https://github.com/microsoft/litebox might somehow allow it too if a tool can be built on top of it, but there is no documentation.

replies(1): >>simonw+Dc
◧◩
3. simonw+Dc[view] [source] [discussion] 2026-02-07 04:05:39
>>OutOfH+G7
Every time I use Docker as a sandbox people warn me to watch out for "container escapes".

I trust Firecracker more because it was built by AWS specifically to sandbox Lambdas, but it doesn't work on macOS and is pretty fiddly to run on Linux.

replies(2): >>OutOfH+O11 >>its-su+4o2
4. nickps+ed[view] [source] 2026-02-07 04:14:10
>>simonw+(OP)
It could be difficult. My first thought would be a SELinux policy like this article attempted:

https://danwalsh.livejournal.com/28545.html

One might have different profiles with different permissions. A network service usually wouldn't need your hone directory while a personal utility might not need networking.

Also, that concept could be mixed with subprocess-style sandboxing. The two processes, main and sandboxed, might have different policies. The sandboxed one can only talk to main process over a specific channel. Nothing else. People usually also meter their CPU, RAM, etc.

INTEGRITY RTOS had language-specific runtimes, esp Ada and Java, that ran directly on the microkernel. A POSIX app or Linux VM could run side by side with it. Then, some middleware for inter-process communication let them talk to each other.

◧◩◪
5. OutOfH+O11[view] [source] [discussion] 2026-02-07 14:59:25
>>simonw+Dc
I think ChatGPT can do a much better job than I can for guiding how to safely use Docker as a sandbox: /share/69875282-1e38-8012-b627-7c0a678f9365

It's not industrial-grade safety for public use, but it'll do for personal use. Other tools for it are also mentioned.

◧◩◪
6. its-su+4o2[view] [source] [discussion] 2026-02-07 23:47:22
>>simonw+Dc
Outside of VM usage, the answer seems to be (on top of containerization and selinux) writing a tight seccomp filter.

Gleaned from https://github.com/containers/bubblewrap/blob/0c408e156b12dd... and https://github.com/containers/bubblewrap/tree/0c408e156b12dd...

[go to top]