T05 · Unauthorized Access and Privilege Escalation
Error
- Location
scripts/run_cancel.sh:47- Finding
Path Traversal Allows Cancellation of Unintended tmux Sessions
- Content
View full analysis
/dev/null | sort) if [[ ${#MATCHES[@]} -eq 1 ]]; then TARGET_DIR="${MATCHES[0]}" elif [[ ${#MATCHES[@]} -gt 1 ]]; then echo "Error: run-id is ambiguous. Use /. Matches:" >&2 printf '%s\n' "${MATCHES[@]}" >&2 exit 2 fi fi if [[ -z "$TARGET_DIR" || ! -d "$TARGET_DIR" ]]; then echo "Error: run-id not found: $RUN_ID" >&2 exit 2 fi META="$TARGET_DIR/task-meta.json" if [[ ! -f "$META" ]]; then echo "Error: task-meta.json not found in $TARGET_DIR" >&2 exit 2 fi TMUX_SESSION=$(jq -r '.tmux_session // ""' "$META") TMUX_SOCKET_NAME=$(jq -r '.tmux_socket_name // ""' "$META") if [[ -z "$TMUX_SESSION" || -z "$TMUX_SOCKET_NAME" ]]; then echo "Error: tmux metadata missing in task-meta.json" >&2 exit 2 fi SOCKET_PATH="$SOCKET_DIR/$TMUX_SOCKET_NAME" TARGET="${TMUX_SESSION}:0.0" set +e tmux -S "$SOCKET_PATH" send-keys -t "$TARGET" -l -- "/ralph-loop:cancel-ralph" tmux -S "$SOCKET_PATH" send-keys -t "$TARGET" Enter sleep 1 tmux -S "$SOCKET_PATH" send-keys -t "$TARGET" -l -- "/exit" tmux -S "$SOCKET_PATH" send-keys -t "$TARGET" Enter sleep 2 tmux -S "$SOCKET_PATH" kill-session -t "$TMUX_SESSION" set -e jq --arg ts "$(date -Iseconds)" '. + {status:"cancelled", completed_at:$ts, exit_code:130}' "$META" > "$META.tmp" && mv "$META.tmp" "$META" ``` ### Technical Analysis When the supplied run identifier contains a slash, it is directly appended to `RESULTS_BASE`. The resulting path is only checked with `-d`; it is not canonicalized, and the script does not verify that ...[truncated 2126 chars]- Remediation
View remediation
&2 exit 2 ;; esac ``` 5. Enforce the documented `/` structure rather than accepting arbitrary slash-containing paths. 6. Validate `tmux_socket_name` as a simple socket filename and reject slashes or traversal components. 7. Verify that the resolved socket and session are associated with the selected run, rather than trusting metadata alone. 8. Apply equivalent containment checks after path resolution to mitigate symbolic-link escapes. ]]>
