mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-08 01:51:14 +00:00
security: fix command injection in fly/lib/common.sh bash -c invocations (#1423)
Quote $escaped_cmd inside the -C argument to bash -c in run_server() and interactive_session() to prevent word splitting. Without quotes, even though printf '%q' escapes shell metacharacters, the shell still splits the escaped command on whitespace before passing it to bash -c, enabling potential argument injection. Fixes #1422 Agent: security-auditor Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
c097a9d234
commit
3e13a213f1
1 changed files with 3 additions and 3 deletions
|
|
@ -372,12 +372,12 @@ run_server() {
|
|||
elif command -v gtimeout &>/dev/null; then timeout_bin="gtimeout"
|
||||
fi
|
||||
if [[ -n "${timeout_bin}" ]]; then
|
||||
"${timeout_bin}" "${timeout_secs}" "$fly_cmd" ssh console -a "$FLY_APP_NAME" -C "bash -c $escaped_cmd" --quiet 2>/dev/null
|
||||
"${timeout_bin}" "${timeout_secs}" "$fly_cmd" ssh console -a "$FLY_APP_NAME" -C "bash -c \"$escaped_cmd\"" --quiet 2>/dev/null
|
||||
return $?
|
||||
fi
|
||||
fi
|
||||
|
||||
"$fly_cmd" ssh console -a "$FLY_APP_NAME" -C "bash -c $escaped_cmd" --quiet 2>/dev/null
|
||||
"$fly_cmd" ssh console -a "$FLY_APP_NAME" -C "bash -c \"$escaped_cmd\"" --quiet 2>/dev/null
|
||||
}
|
||||
|
||||
# Upload a file to the machine via base64 encoding through exec
|
||||
|
|
@ -405,7 +405,7 @@ interactive_session() {
|
|||
local escaped_cmd
|
||||
escaped_cmd=$(printf '%q' "$cmd")
|
||||
local session_exit=0
|
||||
"$(_get_fly_cmd)" ssh console -a "$FLY_APP_NAME" -C "bash -c $escaped_cmd" || session_exit=$?
|
||||
"$(_get_fly_cmd)" ssh console -a "$FLY_APP_NAME" -C "bash -c \"$escaped_cmd\"" || session_exit=$?
|
||||
SERVER_NAME="${FLY_APP_NAME:-}" SPAWN_RECONNECT_CMD="fly ssh console -a ${FLY_APP_NAME:-}" \
|
||||
_show_exec_post_session_summary
|
||||
return "${session_exit}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue