A process cannot break out of a chroot if you do things right, namely, run the process under its own user ID (i.e. there must not be any process running as the same user outside the chroot).
Chroot the process to a directory that the process cannot write to and that only contains FIFOs. You'll need to either put the executable and the libraries and data files it needs in that chroot, or else start the process as root, then chroot and then change the user ID.
If you can't involve root, you can use a namespace, but you need a recent kernel for that (≥3.8). First create a user namespace, then inside it chroot and change to an in-namespace user ID with the required absence of privileges.
Alternatively, this can be done (with root's cooperation) through security frameworks such as SELinux or AppArmor: disable all filesystem-related syscalls except open
, read
, write
, close
and lseek
, and restrict open
to the directory containing the FIFOs. Be sure to disable ptrace
as well.
chroot
? Unless it is root it shouldn't be able to AFAIK. You might want to submit a bug report to whatever kernel you use. – Kevin Cox Nov 03 '13 at 22:29LD_PRELOAD
might be a good alternative: http://unix.stackexchange.com/a/64745/7453. Specifically here: http://stackoverflow.com/questions/426230/what-is-the-ld-preload-trick – slm Nov 03 '13 at 22:33