-
Notifications
You must be signed in to change notification settings - Fork 237
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
[merged] Call setsid() before executing sandboxed code (CVE-2017-5226) #143
Conversation
This prevents the sandboxed code from getting a controlling tty, which in turn prevents it from accessing the TIOCSTI ioctl and hence faking terminal input. Fixes: containers#142
Can one of the admins verify this patch?
|
bot, add author to whitelist |
bot, test pull request |
Okay, so this affects pretty much every suid binary, and also those binaries for root to run to try to drop privileges. Basically any case where you have processes in different security domains connected to the same pty and same session. Fun. Really need some sort of "suid binary checklist". As far as affecting functionality, one can restore job control by simply allocating a new pty - the sanity check I did was to run We could just tweak the demo shell script to allocate a pty I'd say. |
Hmm, so the kernel code does:
But is it possible for us to regain a reference to the controlling tty somehow? I tried just |
I got curious as to - why does that call to util-linux/util-linux@c6a1746 ➡️ So, this type of thing has been around a long time but not widely socialized I guess. |
I think I'd like to do the seccomp fix in addition at some point, but this looks good. Thanks! |
☀️ Test successful - status-redhatci |
tty_ioctl(4) says no, unless the shell into which the attacker is trying to feed malicious input relinquishes its controlling terminal:
|
This isn't a great fix because it pretty much breaks using bwrap to create an interactive shell |
Let's track regressions/issues from this via new issues? |
The setsid() workaround of containers#143 is problematic, because it e.g. breaks shell job control for bubblewrap instances. So, instead we use a seccomp approach based on: util-linux/util-linux@8e49250 However, since we don't want to pull in any more dependencies into the setuid binary we pre-compile the seccomp code during the build. If libseccomp is not available on your architecture, we still support the old fix with --disable-seccomp-tty-fix.
The setsid() workaround of containers#143 is problematic, because it e.g. breaks shell job control for bubblewrap instances. So, instead we use a seccomp approach based on: util-linux/util-linux@8e49250 However, since we don't want to pull in any more dependencies into the setuid binary we pre-compile the seccomp code during the build. If libseccomp is not available on your architecture, we still support the old fix with --disable-seccomp-tty-fix.
The setsid() workaround of containers#143 is problematic, because it e.g. breaks shell job control for bubblewrap instances. So, instead we use a seccomp approach based on: util-linux/util-linux@8e49250 However, since we don't want to pull in any more dependencies into the setuid binary we pre-compile the seccomp code during the build. If libseccomp is not available on your architecture, we still support the old fix with --disable-seccomp-tty-fix.
The setsid() workaround of containers#143 is problematic, because it e.g. breaks shell job control for bubblewrap instances. So, instead we use a seccomp approach based on: util-linux/util-linux@8e49250 However, since we don't want to pull in any more dependencies into the setuid binary we pre-compile the seccomp code during the build. If libseccomp is not available on your architecture, we still support the old fix with --disable-seccomp-tty-fix. This fixes containers#147
This prevents the sandboxed code from getting a controlling tty,
which in turn prevents it from accessing the TIOCSTI ioctl and hence
faking terminal input.
Fixes: #142
Note that this breaks shell job control:
I think that's an acceptable sacrifice, but if you disagree, the other mechanism seen in setuid things seems to be non-trivial use of seccomp: util-linux/util-linux@8e49250