← All posts

no-release of seccomp-nurse

This post in a nutshell
This has been a draft since my presentation at Ekoparty; I will force myself to not procrastinate this time. This post announces the no-release of seccomp-nurse (it is not a release because it is still an advanced proof of concept). Quick links:


seccomp-nurse is a generic sandbox environment for Linux, which doesn’t require any recompilation. Its purpose is to run legit applications in a hostile environment. I repeat, it is not designed to run a malicious binary.

How does it work? The following figure describes the architecture of seccomp-nurse. You can see two processes, one running the untrusted code and the trusted one. The trusted process is in charge of intercepting syscalls and checking if the action is allowed.\




***How do we intercept syscalls? ***By using an x86_32 hack. If you remember my previous post, I described how the GNU Libc was executing syscalls: by making an indirect call in the VDSO. seccomp-nurse overrides this page in order to call our own function instead of performing the syscall. Our handler retrieves CPU registers and directly sends them to the trusted process through a socket. The trusted process checks its policy engine, like: “can this process open this file?”

***If an action is allowed, how do we execute it? ***SECCOMP only permits 4 syscalls; how do we do it? Well. The SECCOMP flag is limited to the thread scope; that means that if a process has two threads, one can be sandboxed (which will be called untrustee) and the other (called trustee) is free to do whatever it wants; furthermore, if threads share everything, any action done in one thread has an impact on the other. This is pretty cool! But so dangerous!

Indeed, everything is shared; only the CPU registers are not shared between threads; that’s all! The trustee must consider its environment as hostile: its code must not make any memory accesses; only registers can be used. That’s why this part is written in assembly in order to control every instruction. It has been designed to be as simple as possible because this is the keystone of the sandbox; the security of the system relies on it.

This routine is completely dummy and has no intelligence at all; everything is done in the trusted process; the trustee understands only these commands:\

  • Execute this syscall
  • Raise a SIGTRAP (for debugging purposes)
  • Native exit
  • Poke/Peek memory

***How is information exchanged between both processes? ***Thanks to POSIX shared memory, marked as read-only for the untrusted process. That way, when the trusted process wants to delegate a syscall, it writes the values of all registers in this shared memory and notifies the trustee to execute it. With this mechanism, there is no race condition: all syscall arguments are copied so they cannot be modified after the policy check.

***Limitations: ***Because of our way of intercepting syscalls, we can only run dynamically linked binaries on 32-bit systems, using the GNU Libc. It is hoped that the situation will improve greatly in the following weeks… Stay tuned!

***Performance: ***Hahem. I don’t know. Each time the untrustee makes a syscall, our sandbox makes a lot of back-and-forth trips between both processes (one back and forth = at least one read, one write).
\