dracut/0040-fix-base-escape-die-message-in-emergency-hook-script.patch
Pavel Valena 2af42b1801 build: batch of fixes 2026-08-13
- fix(qemu): add missing bochs module explicitly
- fix(base): escape die() message in emergency hook script
- fix(base): replace eval with safe variable indirection in splitsep and export_n

Resolves: RHEL-172462,RHEL-210943

From-source-git-commit: 2a395c7d4abe8e26836ecf109ab69600d4243e03
2026-08-13 16:43:22 +02:00

48 lines
1.7 KiB
Diff

From daed5d8f3691580a6b9b72e54d7bfc5fb6ded4df Mon Sep 17 00:00:00 2001
From: Pavel Valena <pvalena@redhat.com>
Date: Tue, 28 Jul 2026 04:03:13 +0200
Subject: [PATCH 40/41] fix(base): escape die() message in emergency hook
script
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
die() appends its error message to $hookdir/emergency/01-die.sh using
echo "warn dracut: FATAL: \"$*\"", which is later sourced by
emergency_shell(). When die() is called with DHCP-controlled data —
specifically $netroot derived from the DHCP ROOT_PATH option via
netroot.sh's handler-resolution failure path — a command-substitution
sequence such as $(cmd) embedded in that data executes as root when
dracut sources the emergency hook directory.
Replace `echo` with `printf '%q'` to shell-escape the message before
writing it into the hook script, preventing command injection via
DHCP-controlled values that reach die() through error paths.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
(cherry picked from commit 508599e7864c8902bbc5480a0f4d20804d9dd41a)
Resolves: RHEL-210943
---
modules.d/99base/dracut-lib.sh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
index 05c361c6..855305b3 100755
--- a/modules.d/99base/dracut-lib.sh
+++ b/modules.d/99base/dracut-lib.sh
@@ -410,7 +410,8 @@ die() {
} > /dev/kmsg
{
- echo "warn dracut: FATAL: \"$*\""
+ printf 'warn dracut: FATAL: %q\n' "$*"
+
echo "warn dracut: Refusing to continue"
} >> $hookdir/emergency/01-die.sh
[ -d /run/initramfs ] || mkdir -p -- /run/initramfs
--
2.55.0