Kernel hardening / security documentation
Below is document about kernel security I have mentioned on the
irc. But looking at it some more, TSC might have been looking at
easier "turn this CONFIG on and this off" kind of hardening. I'll look
for those kind of suggestions, too.
Good and bad ideas w.r.t. kernel and security
Kernel tries to provide many security guarantees at different
levels. Still, some things are easier to guarantee than others, and
some security barriers are really important, while others... not so
Kernel should be secure against remote attackers.
And it reasonably is, when not, we get it fixed with high priority.
Kernel should protect itself and other users against local, non-priviledged users.
Tries, but attack surface is big.
People don't care about DoS attacks much.
=> Running untrusted code is a bad idea. Forkbomb is few characters in sh.
Fast, out-of-order CPUs leak user data via timing side-channels. Those
CPUs should not process sensitive data. JITs can be used to extract the data.
We can try to work around the problems and apply vendor-provided
workarounds, but there are likely more problems in future. Similar
bugs are hidden in CPU microarchitectures, and in particular
Spectre workarounds are whack-a-mole and thus incomplete.
Hyperthreading makes those attacks easier.
=> Use suitable CPUs to process sensitive data.
BPF is in-kernel JIT
=> Don't use BPF, make sure it is disabled on your configurations.
Filesystems are complex, robustness against malformed filesystems is hard.
Some filesystems try to be robust against filesystems corruption,
and some don't even try. Some perform checks during mount, but
that means that malicious device can work around them.
=> Don't mount untrusted filesystems. If you have to, use simple and
common filesystem. VFAT might be good choice.
Kernel should protect itself against local users with CAP_XX.
Yes, there's capability system, and in theory capabilities should be separated.
=> Don't rely on that. Noone else does.
Some systems try to protect themselves against people with physical access.
Laws of physics says it is impossible, but people can still try to
make it more costly for the "attacker".
=> Please don't rely on that.
Coredumps are useful for debugging, but random processes leaving files in cwd
may not be welcome
Consider disabling coredumps, perhaps with RLIMIT_CORE=0.
Consider putting all coredumps into single directory with /proc/sys/kernel/core_pattern.
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany