Keep relayed text out of notify-send's option parser
The argv click command closed injection through the hint's value, but the sender still handed the headline and description to notify-send bare. A value beginning with a dash is parsed there as flags, and one shaped like `--hint=string:omarchy-exec-argv:[...]` is read as a hint of its own -- libnotify keys hints in a hash table, so the later of two replaces the earlier and a forged headline outranks the vector --exec built. That is reachable without any --exec in sight: omarchy-tailscale-send passes a single file's basename verbatim as the description, so a file named like the hint gives its click action to whoever chose the name. Put the headline and description behind a `--` so notify-send reads them as text, and refuse any pass-through word carrying omarchy-exec-argv -- --exec is the only thing that may build a click command. Co-Authored-By: Codex XHigh <noreply@openai.com>
This commit is contained in:
co-authored by
Codex XHigh
parent
21cbbf8194
commit
1b15120d27
@@ -97,6 +97,14 @@ while (($# > 0)); do
|
||||
elif parse_omarchy_option "$@"; then
|
||||
shift "$parsed_option_args"
|
||||
else
|
||||
# --exec is the only door to a click command. A relayed title or filename
|
||||
# that lands here -- passthrough is the one position an untrusted value can
|
||||
# still reach notify-send as an option -- must not be able to set the hint
|
||||
# itself, which is the injection this transport exists to close.
|
||||
if [[ $1 == *omarchy-exec-argv* ]]; then
|
||||
echo "The click command hint can only be set with --exec, not passed through." >&2
|
||||
exit 1
|
||||
fi
|
||||
args+=("$1")
|
||||
shift
|
||||
fi
|
||||
@@ -136,8 +144,11 @@ if ((exec_present)); then
|
||||
args+=("--hint=string:omarchy-exec-argv:$exec_argv_json")
|
||||
fi
|
||||
|
||||
# `--` so notify-send reads the headline and description as text. Without it a
|
||||
# headline beginning with a dash is parsed as options ("-rf x" becomes -r), and
|
||||
# one shaped like `--hint=string:...` sets a hint of its own.
|
||||
if [[ -n $description ]]; then
|
||||
notify-send "${args[@]}" "$headline" "$description"
|
||||
notify-send "${args[@]}" -- "$headline" "$description"
|
||||
else
|
||||
notify-send "${args[@]}" "$headline"
|
||||
notify-send "${args[@]}" -- "$headline"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user