Skip to content

implement basic filesystem sandbox #1783

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

LorenzBischof
Copy link
Contributor

The idea is to transparently sandbox all processes, packages, tasks and scripts to the current directory, without the user having to develop inside a container.

This is currently just an idea. I still have to figure out if it is feasible.

@LorenzBischof LorenzBischof marked this pull request as draft March 19, 2025 22:51
@LorenzBischof LorenzBischof force-pushed the push-uvwrmtustnww branch 3 times, most recently from 67f281d to 3e66c51 Compare March 20, 2025 21:40
@domenkozar
Copy link
Member

If this works on macOS, I'll be damned :)

@LorenzBischof
Copy link
Contributor Author

LorenzBischof commented Mar 21, 2025

No, this currently only works on Linux and on supported kernels. The sandboxing is "best-effort" and disabled if not supported. Landlock support is pretty good and getting better. Mac has sandbox_init which was deprecated a long time ago, but still used by chrome.

My goal was to start simple and add upon the implementation once we see it work. For example syscall filtering with Seccomp would be really nice. We could also add other implementations like Bubblewrap (user namespaces), but I prefer these lightweight implementations.

I haven't fully thought this through, but I think the filesystem sandboxing could also be used to make the environment more pure, by only allowing access to the shell Nix closure, which would ensure no other packages are accidentally used within the scripts.

@LorenzBischof LorenzBischof force-pushed the push-uvwrmtustnww branch 2 times, most recently from b0c7c6b to 1211fbf Compare March 23, 2025 13:28
@domenkozar
Copy link
Member

Maybe a more feasible apprach would be to run sandboxing at devenv shell and so everything inside is sandboxed?

That would be tricky for loading things like editor config, etc.

@LorenzBischof
Copy link
Contributor Author

That could also work, but my goal was to enable transparent sandboxing. One main advantage of devenv is that development is not within a container, meaning everything else on the host system stays available.

@gabyx
Copy link
Contributor

gabyx commented May 3, 2025

I like that really! Containers come with heavy problems in CI which turns quickly into nested containers which make things hard etc. So a less container approach is really nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants