]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
sysctl.conf: prevent unintentional writes into attacker-controlled files and FIFOs
authorPeter Müller <peter.mueller@ipfire.org>
Mon, 5 Oct 2020 14:12:18 +0000 (14:12 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 5 Oct 2020 15:07:47 +0000 (15:07 +0000)
Similar to hard- and symlink protection introduced a while ago, this
patch enables protections against unintentional writes into
attacker-controlled regular files or FIFOs, where a program expected to
create new ones. This makes exploiting TOCTOU flaws harder.

See also: https://www.kernel.org/doc/Documentation/sysctl/fs.txt

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
config/etc/sysctl.conf

index d48c7734e2bf4c17377bb1d770a3cf178296785b..be7c07c857daafe58bbf67b11b4d026a54346a1a 100644 (file)
@@ -49,6 +49,11 @@ kernel.dmesg_restrict = 1
 fs.protected_symlinks = 1
 fs.protected_hardlinks = 1
 
+# Don't allow writes to files and FIFOs that we don't own in world writable sticky
+# directories, unless they are owned by the owner of the directory.
+fs.protected_fifos = 2
+fs.protected_regular = 2
+
 # Minimal preemption granularity for CPU-bound tasks:
 # (default: 1 msec#  (1 + ilog(ncpus)), units: nanoseconds)
 kernel.sched_min_granularity_ns = 10000000