nixos/hardened: enable user namespaces for root
linux-hardened sets kernel.unprivileged_userns_clone=0 by default; see anthraxx/linux-hardened@104f44058f. This allows the Nix sandbox to function while reducing the attack surface posed by user namespaces, which allow unprivileged code to exercise lots of root-only code paths and have lead to privilege escalation vulnerabilities in the past. We can safely leave user namespaces on for privileged users, as root already has root privileges, but if you're not running builds on your machine and really want to minimize the kernel attack surface then you can set security.allowUserNamespaces to false. Note that Chrome's sandbox requires either unprivileged CLONE_NEWUSER or setuid, and Firefox's silently reduces the security level if it isn't allowed (see about:support), so desktop users may want to set: boot.kernel.sysctl."kernel.unprivileged_userns_clone" = true;
This commit is contained in:
parent
84f258bf09
commit
ad9bfe2254
|
@ -21,8 +21,6 @@ with lib;
|
||||||
|
|
||||||
security.lockKernelModules = mkDefault true;
|
security.lockKernelModules = mkDefault true;
|
||||||
|
|
||||||
security.allowUserNamespaces = mkDefault false;
|
|
||||||
|
|
||||||
security.protectKernelImage = mkDefault true;
|
security.protectKernelImage = mkDefault true;
|
||||||
|
|
||||||
security.allowSimultaneousMultithreading = mkDefault false;
|
security.allowSimultaneousMultithreading = mkDefault false;
|
||||||
|
|
|
@ -76,7 +76,8 @@ import ./make-test.nix ({ pkgs, ...} : {
|
||||||
|
|
||||||
# Test userns
|
# Test userns
|
||||||
subtest "userns", sub {
|
subtest "userns", sub {
|
||||||
$machine->fail("unshare --user");
|
$machine->succeed("unshare --user true");
|
||||||
|
$machine->fail("su -l alice -c 'unshare --user true'");
|
||||||
};
|
};
|
||||||
|
|
||||||
# Test dmesg restriction
|
# Test dmesg restriction
|
||||||
|
|
Loading…
Reference in a new issue