Skip to contentSkip to conversation

grub-mkconfig: restore umask for grub.cfg

PATCH In review Michael Chang 2 participants 2 messages Dec 3, 2021 – Dec 8, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 grub-mkconfig: restore umask for grub.cfg

Since 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 grub-mkconfig. The resulting wrong permission (0644) would allow unprivileged users to read grub's 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 set the file mode of creation to 0600 preventing unprivileged access.

Fixes CVE-2021-3981
---
 util/grub-mkconfig.in | 2 ++
 1 file changed, 2 insertions(+)
util/grub-mkconfig.in +2 -0
index c3ea7612e..41af98135 100644
@@ -301,7 +301,9 @@ 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
Signature · 1 line
2.31.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Michael Chang via Grub-devel

Since 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 grub-mkconfig. The resulting wrong permission (0644) would allow unprivileged users to read grub's configuration file content. This presents a low confidentiality risk as grub.cfg may contain non-secured plain-text passwords.

Quoted 6 lines

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

Fixes CVE-2021-3981

Daniel