MINIJAIL0 "1" "March 2016" "Chromium OS" "User Commands"
NAME
minijail0 - sandbox a process
SYNOPSIS
minijail0 [OPTION]... <PROGRAM> [args]...
DESCRIPTION

Runs PROGRAM inside a sandbox.

-a <table> Run using the alternate syscall table named table. Only available on kernels and architectures that support the PR_ALT_SYSCALL option of prctl(2).

-b <src>[,<dest>[,<writeable>]] Bind-mount src into the chroot directory at dest, optionally writeable. The src path must be an absolute path. If dest is not specified, it will default to src. If the destination does not exist, it will be created as a file or directory based on the src type (including missing parent directories).

-c <caps> Restrict capabilities to caps. When used in conjunction with -u and -g, this allows a program to have access to only certain parts of root's default privileges while running as another user and group ID altogether. Note that these capabilities are not inherited by subprocesses of the process given capabilities unless those subprocesses have POSIX file capabilities. See capabilities(7).

-C <dir> Change root (using chroot(2)) to dir.

-d, --mount-dev Create a new /dev mount with a minimal set of nodes. Implies -v. Additional nodes can be bound with the -b or -k options. The initial set of nodes are: full null tty urandom zero. Symlinks are also created for: fd ptmx stderr stdin stdout.

-e[file] Enter a new network namespace, or if file is specified, enter an existing network namespace specified by file which is typically of the form /proc/<pid>/ns/net.

-f <file> Write the pid of the jailed process to file.

-g <group> Change groups to group, which may be either a group name or a numeric group ID.

-G Inherit all the supplementary groups of the user specified with -u. It is an error to use this option without having specified a user name to -u.

-h Print a help message.

-H Print a help message detailing supported system call names for seccomp_filter. (Other direct numbers may be specified if minijail0 is not in sync with the host kernel or something like 32/64-bit compatibility issues exist.)

-I Run program as init (pid 1) inside a new pid namespace (implies -p).

-k <src>,<dest>,<type>[,<flags>[,<data>]] Mount src, a type filesystem, at dest. If a chroot or pivot root is active, dest will automatically be placed below that path. The flags field is optional and is a hex constant. These represent the MS_XXX settings (see mount(2) for details). Their values can be looked up in the sys/mount.h header file. 0xe is a common value here (a writable mount with nodev/nosuid/noexec bits set), and it is strongly recommended that all mounts have these three bits set whenever possible. The data field is optional and is a comma delimited string (see mount(2) for details). It is passed directly to the kernel, so all fields here are filesystem specific. If the mount is not a pseudo filesystem (e.g. proc or sysfs), src path must be an absolute path (e.g. /dev/sda1 and not sda1). If the destination does not exist, it will be created as a directory (including missing parent directories).

-K[mode] Don't mark all existing mounts as MS_PRIVATE. This option is dangerous as it negates most of the functionality of -v. You very likely don't need this. You may specify a mount propagation mode in which case, that will be used instead of the default MS_PRIVATE. See the mount(2) man page and the kernel docs Documentation/filesystems/sharedsubtree.txt for more technical details, but a brief guide:

\[bu] slave Changes in the parent mount namespace will propagate in, but changes in this mount namespace will not propagate back out. This is usually what people want to use.
\[bu] private No changes in either mount namespace will propagate. This is the default behavior if you don't specify -K.
\[bu] shared Changes in the parent and this mount namespace will freely propagate back and forth. This is not recommended.
\[bu] unbindable Mark all mounts as unbindable.

-l Run inside a new IPC namespace. This option makes the program's System V IPC namespace independent.

-L Report blocked syscalls to syslog when using seccomp filter. This option will force certain syscalls to be allowed in order to achieve this, depending on the system.

-m[<uid> <loweruid> <count>[,<uid> <loweruid> <count>]] Set the uid mapping of a user namespace (implies -pU). Same arguments as newuidmap(1). Multiple mappings should be separated by ','. With no mapping, map the current uid to root inside the user namespace.

-M[<uid> <loweruid> <count>[,<uid> <loweruid> <count>]] Set the gid mapping of a user namespace (implies -pU). Same arguments as newgidmap(1). Multiple mappings should be separated by ','. With no mapping, map the current gid to root inside the user namespace.

-n Set the process's no_new_privs bit. See prctl(2) and the kernel source file Documentation/prctl/no_new_privs.txt for more info.

-N Run inside a new cgroup namespace. This option runs the program with a cgroup view showing the program's cgroup as the root. This is only available on v4.6+ of the Linux kernel.

-p Run inside a new PID namespace. This option will make it impossible for the program to see or affect processes that are not its descendants. This implies -v and -r, since otherwise the process can see outside its namespace by inspecting /proc.

-P <dir> Set dir as the root fs using pivot_root. Implies -v, not compatible with -C.

-r Remount /proc readonly. This implies -v. Remounting /proc readonly means that even if the process has write access to a system config knob in /proc (e.g., in /sys/kernel), it cannot change the value.

-R <rlim_type>,<rlim_cur>,<rlim_max> Set an rlimit value, see getrlimit(2) for allowed values. The string unlimited can be used for rlim_cur and rlim_max, which will translate to RLIM_INFINITY.

-s Enable seccomp(2) in mode 1, which restricts the child process to a very small set of system calls. You most likely do not want to use this with the seccomp filter mode (-S) as they are completely different (even though they have similar names).

-S <arch-specific seccomp_filter policy file> Enable seccomp(2) in mode 13 which restricts the child process to a set of system calls defined in the policy file. Note that system calls often change names based on the architecture or mode. (uname -m is your friend.)

-t[size] Mounts a tmpfs filesystem on /tmp. /tmp must exist already (e.g. in the chroot). The filesystem has a default size of "64M", overridden with an optional argument. It has standard /tmp permissions (1777), and is mounted nodev/noexec/nosuid. Implies -v.

-T <type> Assume binary's ELF linkage type is type, which must be either 'static' or 'dynamic'. Either setting will prevent minijail0 from manually parsing the ELF header to determine the type. Type 'static' can be used to avoid preload hooking, and will force minijail0 to instead set everything up before the program is executed. Type 'dynamic' will force minijail0 to preload libminijailpreload.so to setup hooks, but will fail on actually statically-linked binaries.

-u <user> Change users to user, which may be either a user name or a numeric user ID.

-U Enter a new user namespace (implies -p).

-v Run inside a new VFS namespace. This option makes the program's mountpoints independent of the rest of the system's.

-V <file> Enter the VFS namespace specified by file.

-w Create and join a new anonymous session keyring. See keyrings(7) for more details.

-y Keep the current user's supplementary groups.

-Y Synchronize seccomp filters across thread group.

--uts[=hostname] Create a new UTS/hostname namespace, and optionally set the hostname in the new namespace to hostname.

--logging=<system> Use system as the logging system. system must be one of syslog (the default) or stderr.

--profile <profile> Choose from one of the available sandboxing profiles, which are simple way to get a standardized environment. See the "SANDBOXING PROFILES" section below for the full list of supported values for profile.

SANDBOXING PROFILES
The following sandboxing profiles are supported:

minimalistic-mountns Set up a minimalistic mount namespace. Equivalent to -v -P /var/empty -b /,/ -b /proc,/proc -t -r --mount-dev.

IMPLEMENTATION
This program is broken up into two parts: minijail0 (the frontend) and a helper library called libminijailpreload. Some jailings can only be achieved from the process to which they will actually apply - specifically capability use (since capabilities are not inherited to an exec'd process unless the exec'd process has POSIX file capabilities), seccomp (since we can't exec() once we're seccomp'd), and ptrace-disable (which is always cleared on exec()). To this end, libminijailpreload is forcibly loaded into all dynamically-linked target programs if any of these restrictions are in effect; we pass the specific restrictions in an environment variable which the preloaded library looks for. The forcibly-loaded library then applies the restrictions to the newly-loaded program.
AUTHOR
The Chromium OS Authors <chromiumos-dev@chromium.org>
COPYRIGHT
Copyright \(co 2011 The Chromium OS Authors License BSD-like.
"SEE ALSO"
libminijail.h minijail0(5)