nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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