Skip to content

Commit c0e7f6a

Browse files
committed
Explicitly unset QREXEC_ variables
QREXEC_SERVICE_ARGUMENT, QREXEC_REQUESTED_TARGET and QREXEC_REQUESTED_TARGET_KEYWORD should not be in the environment of the child process unless explicitly set by the qrexec call. Explicitly unset them. Also avoid relying on QREXEC_SERVICE_ARGUMENT not containing glob characters or characters in $IFS. Commands sent from a VM cannot have them due to the sanitization in qrexec-daemon, but commands sent from dom0 could. Fixes: QubesOS/qubes-issues#9091
1 parent 7f78441 commit c0e7f6a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/qubes-rpc-multiplexer

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ if ! [ $# = 2 -o $# = 4 ] ; then
2222
echo "$0: bad argument count, usage: $0 SERVICE-NAME REMOTE-DOMAIN-NAME [REQUESTED_TARGET_TYPE REQUESTED_TARGET]" >&2
2323
exit 1
2424
fi
25+
# Avoid inheriting these from the environment
26+
unset QREXEC_REQUESTED_TARGET QREXEC_REQUESTED_TARGET_KEYWORD QREXEC_SERVICE_ARGUMENT
2527
export QREXEC_REQUESTED_TARGET_TYPE="$3"
2628
if [ "$QREXEC_REQUESTED_TARGET_TYPE" = "name" ]; then
2729
export QREXEC_REQUESTED_TARGET="$4"
@@ -51,7 +53,6 @@ for DIR in $QREXEC_SERVICE_PATH; do
5153
done
5254
IFS=$ifs
5355

54-
# shellcheck disable=SC2086
55-
exec "$CFG_FILE" ${QREXEC_SERVICE_ARGUMENT}
56+
exec "$CFG_FILE" ${QREXEC_SERVICE_ARGUMENT:+"$QREXEC_SERVICE_ARGUMENT"}
5657
echo "$0: failed to execute handler for $1" >&2
5758
exit 1

qrexec/tests/socket/agent.py

-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ def test_exec_service(self):
344344
],
345345
)
346346

347-
@unittest.expectedFailure
348347
def test_exec_service_keyword(self):
349348
util.make_executable_service(
350349
self.tempdir,

0 commit comments

Comments
 (0)