git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/keycloak: Set umask before copying sensitive files

`install` copies the files before setting their mode, so there could be a breif window where the secrets are readable by other users without a strict umask.

commit8309368e4c29d0ffa954dde669db7f1a17fcd374 authortalyz <kim.lindberger@gmail.com> dateTue 4 May 2021, 17:12 (6 years ago) parentc2bebf4
1 file changed+4
nixos/modules/services/web-apps/keycloak.nix+4
nixos/modules/services/web-apps/keycloak.nix+4
@@ -652,6 +652,8 @@ in
652652 set -o errexit -o pipefail -o nounset -o errtrace
653653 shopt -s inherit_errexit
654654
655+ umask u=rwx,g=,o=
656+
655657 install -T -m 0400 -o keycloak -g keycloak '${cfg.databasePasswordFile}' /run/keycloak/secrets/db_password
656658 '' + lib.optionalString (cfg.certificatePrivateKeyBundle != null) ''
657659 install -T -m 0400 -o keycloak -g keycloak '${cfg.certificatePrivateKeyBundle}' /run/keycloak/secrets/ssl_cert_pk_bundle
@@ -660,6 +662,8 @@ in
660662 set -o errexit -o pipefail -o nounset -o errtrace
661663 shopt -s inherit_errexit
662664
665+ umask u=rwx,g=,o=
666+
663667 install -m 0600 ${cfg.package}/standalone/configuration/*.properties /run/keycloak/configuration
664668 install -T -m 0600 ${keycloakConfig} /run/keycloak/configuration/standalone.xml
665669