0002-grub-mkconfig-Restore-umask-for-the-grub.cfg.patch 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. From 4c1ad500e73d46c83dec369da85db39ae2fe62dd Mon Sep 17 00:00:00 2001
  2. From: Michael Chang <mchang@suse.com>
  3. Date: Fri, 3 Dec 2021 16:13:28 +0800
  4. Subject: [PATCH] grub-mkconfig: Restore umask for the grub.cfg
  5. The commit ab2e53c8a (grub-mkconfig: Honor a symlink when generating
  6. configuration by grub-mkconfig) has inadvertently discarded umask for
  7. creating grub.cfg in the process of running grub-mkconfig. The resulting
  8. wrong permission (0644) would allow unprivileged users to read GRUB
  9. configuration file content. This presents a low confidentiality risk
  10. as grub.cfg may contain non-secured plain-text passwords.
  11. This patch restores the missing umask and sets the creation file mode
  12. to 0600 preventing unprivileged access.
  13. Fixes: CVE-2021-3981
  14. Signed-off-by: Michael Chang <mchang@suse.com>
  15. Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
  16. Upstream: https://git.savannah.gnu.org/gitweb/?p=grub.git;a=commit;h=0adec29674561034771c13e446069b41ef41e4d4
  17. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  18. ---
  19. util/grub-mkconfig.in | 3 +++
  20. 1 file changed, 3 insertions(+)
  21. diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
  22. index f8cbb8d7a..84f356ea4 100644
  23. --- a/util/grub-mkconfig.in
  24. +++ b/util/grub-mkconfig.in
  25. @@ -300,7 +300,10 @@ and /etc/grub.d/* files or please file a bug report with
  26. exit 1
  27. else
  28. # none of the children aborted with error, install the new grub.cfg
  29. + oldumask=$(umask)
  30. + umask 077
  31. cat ${grub_cfg}.new > ${grub_cfg}
  32. + umask $oldumask
  33. rm -f ${grub_cfg}.new
  34. fi
  35. fi
  36. --
  37. 2.41.0