Blame SOURCES/0489-grub-mkconfig-restore-umask-for-grub.cfg.patch

b32e65
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
b32e65
From: Michael Chang via Grub-devel <grub-devel@gnu.org>
b32e65
Date: Fri, 3 Dec 2021 16:13:28 +0800
b32e65
Subject: [PATCH] grub-mkconfig: restore umask for grub.cfg
b32e65
b32e65
Since commit:
b32e65
b32e65
  ab2e53c8a grub-mkconfig: Honor a symlink when generating configuration
b32e65
by grub-mkconfig
b32e65
b32e65
has inadvertently discarded umask for creating grub.cfg in the process
b32e65
of grub-mkconfig. The resulting wrong permission (0644) would allow
b32e65
unprivileged users to read grub's configuration file content. This
b32e65
presents a low confidentiality risk as grub.cfg may contain non-secured
b32e65
plain-text passwords.
b32e65
b32e65
This patch restores the missing umask and set the file mode of creation
b32e65
to 0600 preventing unprivileged access.
b32e65
b32e65
Fixes: CVE-2021-3981
b32e65
b32e65
Signed-off-by: Michael Chang <mchang@suse.com>
b32e65
(cherry picked from commit 2acad06610da1488bfa387f56a847119ab758766)
b32e65
(cherry picked from commit 583bc3a468c9782696b2703e1098590f6f820add)
b32e65
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
b32e65
---
b32e65
 util/grub-mkconfig.in | 2 ++
b32e65
 1 file changed, 2 insertions(+)
b32e65
b32e65
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
b32e65
index 5e643e169..a1c00776d 100644
b32e65
--- a/util/grub-mkconfig.in
b32e65
+++ b/util/grub-mkconfig.in
b32e65
@@ -317,7 +317,9 @@ and /etc/grub.d/* files or please file a bug report with
b32e65
     exit 1
b32e65
   else
b32e65
     # none of the children aborted with error, install the new grub.cfg
b32e65
+    oldumask=$(umask); umask 077
b32e65
     cat ${grub_cfg}.new > ${grub_cfg}
b32e65
+    umask $oldumask
b32e65
     rm -f ${grub_cfg}.new
b32e65
   fi
b32e65
 fi