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

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