]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
grub-mkconfig: Restore umask for the grub.cfg
authorMichael Chang <mchang@suse.com>
Fri, 3 Dec 2021 08:13:28 +0000 (16:13 +0800)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 23 Dec 2021 00:43:59 +0000 (01:43 +0100)
The commit ab2e53c8a (grub-mkconfig: Honor a symlink when generating
configuration by grub-mkconfig) has inadvertently discarded umask for
creating grub.cfg in the process of running grub-mkconfig. The resulting
wrong permission (0644) would allow unprivileged users to read GRUB
configuration file content. This presents a low confidentiality risk
as grub.cfg may contain non-secured plain-text passwords.

This patch restores the missing umask and sets the creation file mode
to 0600 preventing unprivileged access.

Fixes: CVE-2021-3981
Signed-off-by: Michael Chang <mchang@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
util/grub-mkconfig.in

index c3ea7612e129c4fe9f23e4a4927cbfcb07bd1c8e..62335d02728d14f839ed4e6aa67fd83ab574a376 100644 (file)
@@ -301,7 +301,10 @@ and /etc/grub.d/* files or please file a bug report with
     exit 1
   else
     # none of the children aborted with error, install the new grub.cfg
+    oldumask=$(umask)
+    umask 077
     cat ${grub_cfg}.new > ${grub_cfg}
+    umask $oldumask
     rm -f ${grub_cfg}.new
   fi
 fi