nixpkgs/nixos/modules
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
..
config nixos/users-groups: check format of passwd entries 2021-04-22 13:18:38 +00:00
hardware Merge pull request #119706 from nyanotech/master 2021-04-24 03:49:09 +02:00
i18n/input-method input methods: add kime 2021-04-19 03:05:07 +09:00
installer nixos-install: fix flake command 2021-04-24 11:49:59 +02:00
misc nixos/misc/ids: reclaim uid for disnix 2021-03-28 21:40:44 +02:00
profiles nixos/hidepid: drop the module as the hidepid mount option is broken 2021-02-21 13:51:37 +01:00
programs nixos/module: example referenced old ffmpeg 2021-04-30 09:43:18 +08:00
security Merge pull request #116369 from m1cr0man/master 2021-03-23 21:31:42 +01:00
services wireguard module: generatePrivateKeyFile: Fix chmod security race. Fixes #121288 2021-04-30 18:55:38 +02:00
system Merge pull request #114637 from KaiHa/pr/fix-systemd-boot-builder 2021-04-25 11:35:00 +01:00
tasks nixos/cpu-freq: fix typo in description 2021-04-21 22:03:18 +02:00
testing treewide: use perl.withPackages when possible 2021-03-31 21:35:37 +02:00
virtualisation nixos/hyperv: bail gracefully if device is missing 2021-04-29 09:37:17 +08:00
module-list.nix init duckling service 2021-04-27 10:41:07 -07:00
rename.nix quagga: remove 2021-04-22 12:48:48 +02:00