nsjail/config.proto

282 lines
13 KiB
Protocol Buffer
Raw Normal View History

2017-05-26 11:01:22 +08:00
syntax = "proto2";
2017-05-26 07:55:02 +08:00
package nsjail;
2017-05-26 10:37:50 +08:00
enum Mode {
2017-05-27 21:40:24 +08:00
LISTEN = 0; /* Listening on a TCP port */
2019-08-04 15:50:34 +08:00
ONCE = 1; /* Running the command once only */
RERUN = 2; /* Re-executing the command (forever) */
2017-05-27 09:59:02 +08:00
EXECVE = 3; /* Executing command w/o the supervisor */
2017-05-26 10:37:50 +08:00
}
2017-05-27 21:40:24 +08:00
/* Should be self explanatory */
enum LogLevel {
2019-08-04 15:50:34 +08:00
DEBUG = 0; /* Equivalent to the '-v' cmd-line option */
INFO = 1; /* Default level */
WARNING = 2; /* Equivalent to the '-q' cmd-line option */
2017-05-27 09:59:02 +08:00
ERROR = 3;
FATAL = 4;
2017-05-26 20:08:09 +08:00
}
message IdMap {
2017-05-27 09:59:02 +08:00
/* Empty string means "current uid/gid" */
optional string inside_id = 1 [default = ""];
optional string outside_id = 2 [default = ""];
/* See 'man user_namespaces' for the meaning of count */
optional uint32 count = 3 [default = 1];
2017-05-27 09:59:02 +08:00
/* Does this map use /usr/bin/new[u|g]idmap binary? */
optional bool use_newidmap = 4 [default = false];
2017-05-26 23:50:28 +08:00
}
message MountPt {
/* Can be skipped for filesystems like 'proc' */
2018-02-12 06:44:43 +08:00
optional string src = 1 [default = ""];
2019-08-29 04:18:58 +08:00
/* Should 'src' path be prefixed with this envar? */
2018-02-12 06:44:43 +08:00
optional string prefix_src_env = 2 [default = ""];
2017-06-12 08:08:16 +08:00
/* If specified, contains buffer that will be written to the dst file */
2018-02-12 06:44:43 +08:00
optional bytes src_content = 3 [default = ""];
2017-06-12 08:08:16 +08:00
/* Mount point inside jail */
2018-02-12 06:44:43 +08:00
required string dst = 4 [default = ""];
2019-08-29 04:18:58 +08:00
/* Should 'dst' path be prefixed with this envar? */
2018-02-12 06:44:43 +08:00
optional string prefix_dst_env = 5 [default = ""];
2017-05-27 09:59:02 +08:00
/* Can be empty for mount --bind mounts */
optional string fstype = 6 [default = ""];
2017-05-27 09:59:02 +08:00
/* E.g. size=5000000 for 'tmpfs' */
optional string options = 7 [default = ""];
2018-11-07 00:30:04 +08:00
/* Is it a 'mount --bind src dst' type of mount? */
optional bool is_bind = 8 [default = false];
2018-11-07 00:30:04 +08:00
/* Is it a R/W mount? */
optional bool rw = 9 [default = false];
2018-11-07 00:30:04 +08:00
/* Is it a directory? If not specified an internal
2017-05-27 21:40:24 +08:00
heuristics will be used to determine that */
optional bool is_dir = 10;
2017-05-27 21:40:24 +08:00
/* Should the sandboxing fail if we cannot mount this resource? */
optional bool mandatory = 11 [default = true];
2017-09-27 21:36:05 +08:00
/* Is it a symlink (instead of real mount point)? */
optional bool is_symlink = 12 [default = false];
/* Is it a nosuid mount */
optional bool nosuid = 13 [default = false];
/* Is it a nodev mount */
optional bool nodev = 14 [default = false];
/* Is it a noexec mount */
optional bool noexec = 15 [default = false];
2017-05-27 07:16:12 +08:00
}
enum RLimit {
VALUE = 0; /* Use the provided value */
SOFT = 1; /* Use the current soft rlimit */
HARD = 2; /* Use the current hard rlimit */
INF = 3; /* Use RLIM64_INFINITY */
}
message Exe {
/* Will be used both as execv's path and as argv[0] */
2019-04-02 04:43:17 +08:00
required string path = 1;
2017-05-27 09:59:02 +08:00
/* This will be argv[1] and so on.. */
repeated string arg = 2;
/* Override argv[0] */
optional string arg0 = 3;
/* Should execveat() be used to execute a file-descriptor instead? */
optional bool exec_fd = 4 [default = false];
2017-05-27 08:24:41 +08:00
}
message NsJailConfig {
2017-06-12 08:08:16 +08:00
/* Optional name and description for this config */
optional string name = 1 [default = ""];
repeated string description = 2;
2017-05-28 01:05:42 +08:00
2017-05-27 09:59:02 +08:00
/* Execution mode: see 'msg Mode' description for more */
optional Mode mode = 3 [default = ONCE];
2017-05-27 09:59:02 +08:00
/* Hostname inside jail */
2021-08-11 01:17:33 +08:00
optional string hostname = 4 [default = "NSJAIL"];
2017-05-27 09:59:02 +08:00
/* Initial current working directory for the binary */
2021-08-11 01:17:33 +08:00
optional string cwd = 5 [default = "/"];
2017-05-27 09:59:02 +08:00
2021-06-17 19:57:01 +08:00
/* Defines whether to use switch_root or pivot_root */
2021-08-11 01:17:33 +08:00
optional bool no_pivotroot = 6 [default = false];
2021-08-03 23:46:08 +08:00
2017-05-27 09:59:02 +08:00
/* TCP port to listen to. Valid with mode=LISTEN only */
2021-08-11 01:17:33 +08:00
optional uint32 port = 7 [default = 0];
2017-05-27 09:59:02 +08:00
/* Host to bind to for mode=LISTEN. Must be in IPv6 format */
2021-08-11 01:17:33 +08:00
optional string bindhost = 8 [default = "::"];
2021-02-10 06:13:35 +08:00
/* For mode=LISTEN, maximum number of connections across all IPs */
2021-08-11 01:17:33 +08:00
optional uint32 max_conns = 9 [default = 0];
2017-05-27 09:59:02 +08:00
/* For mode=LISTEN, maximum number of connections from a single IP */
2021-08-11 01:17:33 +08:00
optional uint32 max_conns_per_ip = 10 [default = 0];
2017-05-27 09:59:02 +08:00
/* Wall-time time limit for commands */
2021-08-11 01:17:33 +08:00
optional uint32 time_limit = 11 [default = 600];
2017-05-27 09:59:02 +08:00
/* Should nsjail go into background? */
2021-08-11 01:17:33 +08:00
optional bool daemon = 12 [default = false];
2017-06-19 23:05:01 +08:00
/* Maximum number of CPUs to use: 0 - no limit */
2021-08-11 01:17:33 +08:00
optional uint32 max_cpus = 13 [default = 0];
2017-05-27 10:06:28 +08:00
/* FD to log to. */
2021-08-11 01:17:33 +08:00
optional int32 log_fd = 14;
2019-10-03 01:43:58 +08:00
/* File to save logs to. */
2021-08-11 01:17:33 +08:00
optional string log_file = 15;
2017-05-27 09:59:02 +08:00
/* Minimum log level displayed.
2017-05-27 21:40:24 +08:00
See 'msg LogLevel' description for more */
2021-08-11 01:17:33 +08:00
optional LogLevel log_level = 16;
2017-05-27 10:06:28 +08:00
2017-05-27 09:59:02 +08:00
/* Should the current environment variables be kept
2017-05-27 21:40:24 +08:00
when executing the binary */
2021-08-11 01:17:33 +08:00
optional bool keep_env = 17 [default = false];
2019-08-29 04:18:58 +08:00
/* EnvVars to be set before executing binaries. If the envar doesn't contain '='
(e.g. just the 'DISPLAY' string), the current envar value will be used */
2021-08-11 01:17:33 +08:00
repeated string envar = 18;
2017-05-27 10:06:28 +08:00
2017-07-05 23:29:57 +08:00
/* Should capabilities be preserved or dropped */
2021-08-11 01:17:33 +08:00
optional bool keep_caps = 19 [default = false];
2017-07-06 07:12:13 +08:00
/* Which capabilities should be preserved if keep_caps == false.
Format: "CAP_SYS_PTRACE" */
2021-08-11 01:17:33 +08:00
repeated string cap = 20;
2017-05-27 09:59:02 +08:00
/* Should nsjail close FD=0,1,2 before executing the process */
2021-08-11 01:17:33 +08:00
optional bool silent = 21 [default = false];
2017-05-27 09:59:02 +08:00
/* Should the child process have control over terminal?
2017-05-27 21:40:24 +08:00
Can be useful to allow /bin/sh to provide
2017-11-02 20:08:08 +08:00
job control / signals. Dangerous, can be used to put
characters into the controlling terminal back */
2021-08-11 01:17:33 +08:00
optional bool skip_setsid = 22 [default = false];
2018-06-25 09:12:27 +08:00
/* Redirect sdterr of the process to /dev/null instead of the socket or original TTY */
2021-08-11 01:17:33 +08:00
optional bool stderr_to_null = 23 [default = false];
2017-05-27 09:59:02 +08:00
/* Which FDs should be passed to the newly executed process
2017-05-27 21:40:24 +08:00
By default only FD=0,1,2 are passed */
2021-08-11 01:17:33 +08:00
repeated int32 pass_fd = 24;
2017-05-27 09:59:02 +08:00
/* Setting it to true will allow to have set-uid binaries
2017-05-27 21:40:24 +08:00
inside the jail */
2021-08-11 01:17:33 +08:00
optional bool disable_no_new_privs = 25 [default = false];
2017-05-27 09:59:02 +08:00
2017-10-07 04:44:55 +08:00
/* Various rlimits, the rlimit_as/rlimit_core/... are used only if
rlimit_as_type/rlimit_core_type/... are set to RLimit::VALUE */
2021-08-11 01:17:33 +08:00
optional uint64 rlimit_as = 26 [default = 4096]; /* In MiB */
optional RLimit rlimit_as_type = 27 [default = VALUE];
optional uint64 rlimit_core = 28 [default = 0]; /* In MiB */
optional RLimit rlimit_core_type = 29 [default = VALUE];
optional uint64 rlimit_cpu = 30 [default = 600]; /* In seconds */
optional RLimit rlimit_cpu_type = 31 [default = VALUE];
optional uint64 rlimit_fsize = 32 [default = 1]; /* In MiB */
optional RLimit rlimit_fsize_type = 33 [default = VALUE];
optional uint64 rlimit_nofile = 34 [default = 32];
optional RLimit rlimit_nofile_type = 35 [default = VALUE];
/* RLIMIT_NPROC is system-wide - tricky to use; use the soft limit value by
* default here */
2021-08-11 01:17:33 +08:00
optional uint64 rlimit_nproc = 36 [default = 1024];
optional RLimit rlimit_nproc_type = 37 [default = SOFT];
/* In MiB, use the soft limit value by default */
2021-08-11 01:17:33 +08:00
optional uint64 rlimit_stack = 38 [default = 8];
optional RLimit rlimit_stack_type = 39 [default = SOFT];
2021-07-19 22:21:34 +08:00
/* In KB, use the soft limit value by default */
2021-08-11 01:17:33 +08:00
optional uint64 rlimit_memlock = 40 [default = 64];
optional RLimit rlimit_memlock_type = 41 [default = SOFT];
optional uint64 rlimit_rtprio = 42 [default = 0];
optional RLimit rlimit_rtprio_type = 43 [default = SOFT];
optional uint64 rlimit_msgqueue = 44 [default = 1024]; /* In bytes */
optional RLimit rlimit_msgqueue_type = 45 [default = SOFT];
2017-05-27 09:59:02 +08:00
2019-08-19 20:28:45 +08:00
/* Disable all rlimits, default to limits set by parent */
2021-08-11 01:17:33 +08:00
optional bool disable_rl = 46 [default = false];
2019-08-19 20:28:45 +08:00
2017-05-27 09:59:02 +08:00
/* See 'man personality' for more */
2021-08-11 01:17:33 +08:00
optional bool persona_addr_compat_layout = 47 [default = false];
optional bool persona_mmap_page_zero = 48 [default = false];
optional bool persona_read_implies_exec = 49 [default = false];
optional bool persona_addr_limit_3gb = 50 [default = false];
optional bool persona_addr_no_randomize = 51 [default = false];
2017-05-27 09:59:02 +08:00
/* Which name-spaces should be used? */
2021-08-11 01:17:33 +08:00
optional bool clone_newnet = 52 [default = true];
optional bool clone_newuser = 53 [default = true];
optional bool clone_newns = 54 [default = true];
optional bool clone_newpid = 55 [default = true];
optional bool clone_newipc = 56 [default = true];
optional bool clone_newuts = 57 [default = true];
/* Disable for kernel versions < 4.6 as it's not supported there */
2021-08-11 01:17:33 +08:00
optional bool clone_newcgroup = 58 [default = true];
/* Supported with kernel versions >= 5.3 */
2021-08-11 01:17:33 +08:00
optional bool clone_newtime = 59 [default = false];
2017-05-27 09:59:02 +08:00
/* Mappings for UIDs and GIDs. See the description for 'msg IdMap'
2017-05-27 21:40:24 +08:00
for more */
2021-08-11 01:17:33 +08:00
repeated IdMap uidmap = 60;
repeated IdMap gidmap = 61;
2017-05-27 07:16:12 +08:00
/* Should /proc be mounted (R/O)? This can also be added in the 'mount'
section below */
2021-08-11 01:17:33 +08:00
optional bool mount_proc = 62 [default = false];
2017-05-27 09:59:02 +08:00
/* Mount points inside the jail. See the description for 'msg MountPt'
2017-05-27 21:40:24 +08:00
for more */
2021-08-11 01:17:33 +08:00
repeated MountPt mount = 63;
2017-05-27 08:09:21 +08:00
/* Kafel seccomp-bpf policy file or a string:
2017-05-27 21:40:24 +08:00
Homepage of the project: https://github.com/google/kafel */
2021-08-11 01:17:33 +08:00
optional string seccomp_policy_file = 64;
repeated string seccomp_string = 65;
2018-10-24 16:31:14 +08:00
/* Setting it to true makes audit write seccomp logs to dmesg */
2021-08-11 01:17:33 +08:00
optional bool seccomp_log = 66 [default = false];
2017-05-27 09:59:02 +08:00
/* If > 0, maximum cumulative size of RAM used inside any jail */
2021-08-11 01:17:33 +08:00
optional uint64 cgroup_mem_max = 67 [default = 0]; /* In bytes */
/* If > 0, maximum cumulative size of RAM + swap used inside any jail */
optional uint64 cgroup_mem_memsw_max = 91 [default = 0]; /* In bytes */
/* If >= 0, maximum cumulative size of swap used inside any jail */
optional int64 cgroup_mem_swap_max = 92 [default = -1]; /* In bytes */
/* Mount point for cgroups-memory in your system */
2021-08-11 01:17:33 +08:00
optional string cgroup_mem_mount = 68 [default = "/sys/fs/cgroup/memory"];
2017-05-27 09:59:02 +08:00
/* Writeable directory (for the nsjail user) under cgroup_mem_mount */
2021-08-11 01:17:33 +08:00
optional string cgroup_mem_parent = 69 [default = "NSJAIL"];
2017-05-27 09:59:02 +08:00
/* If > 0, maximum number of PIDs (threads/processes) inside jail */
2021-08-11 01:17:33 +08:00
optional uint64 cgroup_pids_max = 70 [default = 0];
/* Mount point for cgroups-pids in your system */
2021-08-11 01:17:33 +08:00
optional string cgroup_pids_mount = 71 [default = "/sys/fs/cgroup/pids"];
2017-05-27 09:59:02 +08:00
/* Writeable directory (for the nsjail user) under cgroup_pids_mount */
2021-08-11 01:17:33 +08:00
optional string cgroup_pids_parent = 72 [default = "NSJAIL"];
2017-05-27 09:59:02 +08:00
2017-10-26 06:35:59 +08:00
/* If > 0, Class identifier of network packets inside jail */
2021-08-11 01:17:33 +08:00
optional uint32 cgroup_net_cls_classid = 73 [default = 0];
2017-10-26 06:35:59 +08:00
/* Mount point for cgroups-net-cls in your system */
2021-08-11 01:17:33 +08:00
optional string cgroup_net_cls_mount = 74 [default = "/sys/fs/cgroup/net_cls"];
2017-10-26 06:35:59 +08:00
/* Writeable directory (for the nsjail user) under cgroup_net_mount */
2021-08-11 01:17:33 +08:00
optional string cgroup_net_cls_parent = 75 [default = "NSJAIL"];
2018-02-04 11:15:19 +08:00
2018-12-05 21:35:16 +08:00
/* If > 0, number of milliseconds of CPU time per second that jailed processes can use */
2021-08-11 01:17:33 +08:00
optional uint32 cgroup_cpu_ms_per_sec = 76 [default = 0];
2018-02-04 11:15:19 +08:00
/* Mount point for cgroups-cpu in your system */
2021-08-11 01:17:33 +08:00
optional string cgroup_cpu_mount = 77 [default = "/sys/fs/cgroup/cpu"];
2018-02-04 11:15:19 +08:00
/* Writeable directory (for the nsjail user) under cgroup_cpu_mount */
2021-08-11 01:17:33 +08:00
optional string cgroup_cpu_parent = 78 [default = "NSJAIL"];
2018-02-04 11:15:19 +08:00
2020-07-28 20:02:34 +08:00
/* Mount point for cgroup v2 in your system */
2021-08-11 01:17:33 +08:00
optional string cgroupv2_mount = 79 [default = "/sys/fs/cgroup"];
2020-07-28 20:02:34 +08:00
/* Use cgroup v2 */
2021-08-11 01:17:33 +08:00
optional bool use_cgroupv2 = 80 [default = false];
2020-07-28 20:02:34 +08:00
/* Should the 'lo' interface be brought up (active) inside this jail? */
2021-08-11 01:17:33 +08:00
optional bool iface_no_lo = 81 [default = false];
2017-05-27 09:59:02 +08:00
/* Put this interface inside the jail */
2021-08-11 01:17:33 +08:00
repeated string iface_own = 82;
2017-05-27 09:59:02 +08:00
/* Parameters for the cloned MACVLAN interface inside jail */
2021-08-11 01:17:33 +08:00
optional string macvlan_iface = 83; /* Interface to be cloned, eg 'eth0' */
optional string macvlan_vs_ip = 84 [default = "192.168.0.2"];
optional string macvlan_vs_nm = 85 [default = "255.255.255.0"];
optional string macvlan_vs_gw = 86 [default = "192.168.0.1"];
optional string macvlan_vs_ma = 87 [default = ""];
optional string macvlan_vs_mo = 88 [default = "private"];
2017-05-27 09:59:02 +08:00
/* Niceness level of the jailed process */
2021-08-11 01:17:33 +08:00
optional int32 nice_level = 89 [default = 19];
/* Binary path (with arguments) to be executed. If not specified here, it
can be specified with cmd-line as "-- /path/to/command arg1 arg2" */
2021-08-11 01:17:33 +08:00
optional Exe exec_bin = 90;
2022-11-23 05:25:15 +08:00
/* Disable rdtsc and rdtscp instructions. WARNING: To make it effective, you also need to
* forbid `prctl(PR_SET_TSC, PR_TSC_ENABLE, ...)` in seccomp rules! (x86 and x86_64 only).
* Dynamic binaries produced by GCC seem to rely on RDTSC, but static ones should work. */
optional bool disable_tsc = 93 [default = false];
/* Set this to true to forward fatal signals to the child process instead
* of always using SIGKILL. */
optional bool forward_signals = 94 [default = false];
/* Check whether cgroupv2 is available, and use it if available. */
optional bool detect_cgroupv2 = 95 [default = false];
2017-05-26 07:55:02 +08:00
}