-
Notifications
You must be signed in to change notification settings - Fork 8
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
restrict current thread only #32
Comments
Hello Giuseppe! This is indeed a limitation with the Go-Landlock API. I introduced it because Go programs are inherently multithreaded. As @l0kod said in containers/common#2126 (comment), the underlying problem here is that there are no proper security boundaries between OS threads. So while it is technically possible to landlock a single thread, an attacker who takes control over the thread can very easily manipulate one of the other (unrestricted) threads to do things on its behalf, e.g. by rewiring one of the many function or object pointers that live in the same address space. So while you can technically landlock individual OS threads from the C API, the enforced policy is easily circumventable if there are other OS threads around. A API that only restricts a single OS thread would also be difficult and error-prone to use, as
I do not understand your code change on containers/common#2126 in full detail though. If you have a deeper reasoning for why this would be safe to do in a single-threaded environment, I'd be interested in it. Maybe I don't understand what you are exactly trying to prevent with it.
|
Comments copied over from containers/common:
|
In my understanding from containers/common#2126, the pull request was closed for now, in favor of running it in a subprocess. The Please feel free to reopen if the topic comes up again. |
These can be detected by checking |
Hello @AkihiroSuda! Pointer rewiring does not need to go through any APIs like these. Any thread that lives in the same address space can manipulate memory used by other threads directly. Also, pointer rewiring is only one example of how a (Landlock-restricted) thread can influence what another (unrestricted) thread is doing. Userspace code (like the Go runtime, your program, and all its (cgo?) dependencies) does not normally enforce any security boundaries between threads. There are likely many places in the standard library and elsewhere where a thread can (purposefully) influence what another thread is doing or which code it is executing. And I do not see a realistic way to get all that userspace code hardened for this use case. Fundamentally, if you enable Landlock on only a subset of your threads, your Trusted Computing Base for the Landlock sandbox is all the code that you have loaded into userspace, and that is not something we can control well enough. |
there are cases where it is desiderable to only lock the current thread, not the entire process,and be usable as:
from my understanding, this is a limitation only with the API, but there is nothing preventing such code to work.
Would it make sense to expand the API to allow limiting the current thread only?
The text was updated successfully, but these errors were encountered: