···47474848 # ... or at least apply some hardening to it
4949 boot.kernel.sysctl."net.core.bpf_jit_harden" = mkDefault true;
5050+5151+ # A recurring problem with user namespaces is that there are
5252+ # still code paths where the kernel's permission checking logic
5353+ # fails to account for namespacing, instead permitting a
5454+ # namespaced process to act outside the namespace with the
5555+ # same privileges as it would have inside it. This is particularly
5656+ # bad in the common case of running as root within the namespace.
5757+ #
5858+ # Setting the number of allowed userns to 0 effectively disables
5959+ # the feature at runtime. Attempting to create a user namespace
6060+ # with unshare will then fail with "no space left on device".
6161+ boot.kernel.sysctl."user.max_user_namespaces" = mkDefault 0;
5062}
+5
nixos/tests/hardened.nix
···2727 # note: this better a be module we normally wouldn't load ...
2828 $machine->fail("modprobe dccp");
2929 };
3030+3131+ # Test userns
3232+ subtest "userns", sub {
3333+ $machine->fail("unshare --user");
3434+ };
3035 '';
3136})