-
Notifications
You must be signed in to change notification settings - Fork 286
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
Add Linux sandbox (seccomp-bpf + Landlock LSM) #386
base: 1.1
Are you sure you want to change the base?
Conversation
Thanks for the review, fixed. No need to rush this, the change is quite intrusive and risky. |
3c1e213
to
d160916
Compare
I'll mark this as WIP for now, best to merge this after everything else is in. |
d091ac5
to
009cdfe
Compare
After some recent changes to I'll work on test coverage a bit more before marking this as finished. |
Landlock is similar to
unveil()
and is available on Linux 5.13+.Since both are inherited by child processes, and there's no way to disable this, we use a trick similar to what browsers are doing — fork a process early, drop privileges on the main one, and use the privileged process for running scripts.
This also lets us remove access to
fork()
/execve()
on OpenBSD for both sandbox levels.Hardware
Only amd64 and aarch64 are supported because I don't have access to anything else, and it's pretty dangerous to "support" other architectures without actually testing them. For example, some architectures use
socketcall
instead of separateaccept
/bind
/connect
/etc, some implementgettimeofday
through VDSO instead of an actual syscall, and so on.If a user wishes to go ahead anyway, they can force-enable the sandbox with:
Security
There is at least one way to circumvent the sandbox, but I believe it will only work with a non-empty
ScriptsInterpreter
. Since tincd has full access to thehosts
subdirectory, the attacker can create ahosts/xxx-up
orhosts/xxx-down
script and ask the script worker to execute it.It shouldn't be possible with an empty interpreter since you need to make the script executable, and both
umask()
and allchmod
-related syscalls are blocked by seccomp.Additionally, we remove write access to existing scripts inside
hosts/
to prevent broken tincd from rewriting them and gaining shell access.Reassigning
ScriptsInterpreter
to another value at runtime shouldn't be possible since script worker uses its own copies of all configuration variables, and access to other processes' memory is prevented by seccomp.tincd also doesn't have write access to its own configuration, so it cannot rewrite the config and restart itself.
Performance
The PR doesn't seem to affect simple
iperf3
between two nodes in any way. The results may be different with hundreds of nodes, but I don't have the hardware to test this.With seccomp-bpf and Landlock
Without sandbox