nixpkgs/nixos
Niklas Hambüchen 0dc08b4138 wireguard module: generatePrivateKeyFile: Fix chmod security race. Fixes #121288
Until now, the `touch + chmod 600 + write` approach made it possible for
an unprivileged local user read the private key file, by opening
the file after the touch, before the read permissions are restricted.

This was only the case if `generatePrivateKeyFile = true` and the parent
directory of `privateKeyFile` already existed and was readable.

This commit fixes it by using `umask`, which ensures kernel-side that
the `touch` creates the file with the correct permissions atomically.

This commit also:

* Removes `mkdir --mode 0644 -p "${dirOf values.privateKeyFile}"`
  because setting permissions `drw-r--r--` ("nobody can enter that dir")
  is awkward. `drwx------` would perhaps make sense, like for `.ssh`.
  However, setting the permissions on the private key file is enough,
  and likely better, because `privateKeyFile` is about that file
  specifically and no docs suggest that there's something special
  about its parent dir.
* Removes the `chmod 0400 "${values.privateKeyFile}"`
  because there isn't really a point in removing write access from
  the owner of the private key.
2021-04-30 18:55:38 +02:00
..
doc Merge pull request #118338 from Izorkin/update-nginx-zlib-ng 2021-04-27 16:36:25 +02:00
lib treewide: use lib.warnIf where appropriate 2021-04-28 21:44:21 +00:00
maintainers treewide: use auto diskSize for make-disk-image 2021-04-24 14:49:07 -04:00
modules wireguard module: generatePrivateKeyFile: Fix chmod security race. Fixes #121288 2021-04-30 18:55:38 +02:00
tests nixos/tests/cage: Fix the test with wlroots 0.13 2021-04-30 15:57:04 +02:00
COPYING
default.nix
README
release-combined.nix
release-small.nix
release.nix nixos: use supportedSystems argument instead of hardcoded list for netboot 2021-04-23 18:34:51 +02:00

*** NixOS ***

NixOS is a Linux distribution based on the purely functional package
management system Nix.  More information can be found at
https://nixos.org/nixos and in the manual in doc/manual.