aboutsummaryrefslogtreecommitdiffstats
path: root/src/fsec-optimize
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kris7topher@gmail.com>2020-02-23 18:52:45 +0100
committerLibravatar Kristóf Marussy <kris7topher@gmail.com>2020-02-23 19:24:35 +0100
commitead0c0138810a42005098559ca9a29925e8499b7 (patch)
tree8d9cc31c5c04ca9e6c7299121acdec9517ce166b /src/fsec-optimize
parentMerge pull request #3239 from kris7t/dhcp-client (diff)
downloadfirejail-ead0c0138810a42005098559ca9a29925e8499b7.tar.gz
firejail-ead0c0138810a42005098559ca9a29925e8499b7.tar.zst
firejail-ead0c0138810a42005098559ca9a29925e8499b7.zip
Harden sbox_run by using fexecve instead of execvp
We require the command passed to sbox_run to be an absolute path, and avoid resolving PATH. Note that PATH-based attacks were already difficult to pull of, because sbox_run clears the environment before executing the command. This patch hopefully makes then impossible. As an additional precaution, we check that the executable is owned by either the root user or the root group, and is not world-writable. The use of O_PATH, fstat and fexecve aims to prevent a race condition when the invoked path (e.g., /usr/lib/firejail/fnet) is owned by root or is a symlink to a binary owned by root, but the containing directory (e.g., /usr/lib/firejail) is somehow owned by a user. This is quite unlikely (but may be possible by abusing some other setuid executable is a specific way), and would allow swapping the binary or symlink to a malicious one after we checked ownership. "Locking in" the file descriptor gets rid of the race condition. We have to get rid of the `/proc/[pid]/comm` check in dhcp_read_pidfile, because fexecve sets the comm value to the fd being exec'd (e.g., 3) instead of the name of the file. This is not a problem, unless by the time we pick up the pidfile of dhclient, it has already crashed, and the pid number have wrapper around. Needless to say, this is extremely unlikely (and does not cause a security issue, anyways).
Diffstat (limited to 'src/fsec-optimize')
0 files changed, 0 insertions, 0 deletions