nixos/config/sysctl: enable common TOCTOU vulnerability mitigations#391473
nixos/config/sysctl: enable common TOCTOU vulnerability mitigations#391473illdefined wants to merge 1 commit intoNixOS:masterfrom
Conversation
|
Seems sensible to me. Some other sources:
Also could do with a merge conflict resolution and maybe some release notes just to be safe. |
|
This feels spooky. Do we have evidence of other distros shipping this? |
|
One of my Arch machines (I don't think I've changed anything): My current NixOS output gives the same (even though I'm pretty sure I've hardened some other stuff) Documentation for /proc/sys/fs/ Even if it doesn't ship as default for any distro the links above show those settings in many hardening guides and would fit in the hardened profile. |
|
I just noticed that these sysctls are already being set as part of the systemd defaults: https://github.com/systemd/systemd/blob/main/sysctl.d/50-default.conf#L50
Debian & Ubuntu: https://salsa.debian.org/kernel-team/linux-base/-/blob/debian/latest/sysctl.d/50-default.conf?ref_type=heads#L50 Please note the slight variation in the default values. The value |
This default configuration file is moved out of the way by the systemd package (cf. https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/os-specific/linux/systemd/default.nix#L810) but then installed by the systemd coredump NixOS module: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/system/boot/systemd/coredump.nix#L71 This means that these defaults are set if and only if I would prefer to always set these sysctls, irrespective of the above configuration option. I believe that defaults of Defaults of I suggest to run all NixOS tests with this PR applied and see if anything breaks.
|
This enables mitigations for some common time‐of‐check‐time‐of‐use (TOCTOU) race vulnerabilities by default, mostly related to use of
/tmp.cf. https://www.kernel.org/doc/Documentation/admin-guide/sysctl/fs.rst
These could instead be moved to the hardened profile, they should however be safe to enable on all systems.
I have been running all my systems with these enabled for years without running into any problems.
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.