sysbox icon indicating copy to clipboard operation
sysbox copied to clipboard

Disabling ASLR not supported in inner "privileged" containers

Open supersat opened this issue 4 years ago • 2 comments

Background: I am working on containerizing a buffer overflow exploit lab for our security class, and one of the issues I ran into is that the default seccomp profile limits the personality() syscall to "safe" values which prevents ASLR from being turned off.

I began investigating sysbox as a way to run "privileged" containers which allow the personality() syscall to disable process ASLR. However, this doesn't seem to work. I'm running sysbox 0.2.1 on Ubuntu 20.04.2.

Steps to reproduce:

  1. On the host, run: docker run --runtime=sysbox-runc -it nestybox/alpine-docker:latest
  2. Start dockerd: dockerd 1>/var/log/dockerd.log 2>&1 &
  3. In the container, create a "privileged" inner container: docker run --privileged -it --rm alpine:3.12
  4. In the inner container, add some packages for simple development and debugging: apk add gcc musl-dev gdb nano
  5. Make a small C program and compile it.
  6. Run the resulting executable under gdb:
(gdb) r
Starting program: /hello
warning: Error disabling address space randomization: Operation not permitted
Hello, world!
[Inferior 1 (process 52) exited normally]
(gdb)

Obviously this is a niche use case so it might not be worth addressing. However, it might be useful for debugging reproduceable crashes inside a container, etc.

supersat avatar Mar 22 '21 23:03 supersat

Hi @supersat ... thanks for filing the issue. Let me take a closer look and will get back to you soon. I need to think carefully about what it would mean for Sysbox to relax limits on the personality() syscall.

ctalledo avatar Mar 22 '21 23:03 ctalledo

Hi @supersat, I've yet to look more closely at the security risks associated for relaxing the limits on the personality() syscall, but in the mean time, it's pretty easy to work-around these limits if you are willing to build sysbox from source (which is pretty easy since the build is done inside a docker container that comes prepackaged with all the build-deps).

If you are willing to build from source, then you can relax the limits on the personality() syscall by simply removing the syscall from this list:

var syscontSyscallAllowRestrList = []string{
	"personality",
}

The code is here:

https://github.com/nestybox/sysbox-runc/blob/4a0e3e60a8b287e157eb22bc365bf62da4ed11a2/libsysbox/syscont/syscalls.go#L361

Hope this helps!

ctalledo avatar Mar 24 '21 04:03 ctalledo