T09 · Insecure Skill Coding Practices
- Location
scripts/ros1_runtime_health_check.sh:112- Finding
Arbitrary Shell Command Execution Through Untrusted State Files
- Content
View full analysis
&2; exit 2; } state_file="${state_file:A}" [[ -f "$state_file" ]] || { echo "[ERROR] state file not found: $state_file" >&2; exit 1; } # shellcheck disable=SC1090 source "$state_file" require_state_var "WORKSPACE_ROOT" require_state_var "ROS_SETUP" require_state_var "LOG_FILE" ``` ```zsh # scripts/ros1_runtime_health_check.sh:157-160 # shellcheck disable=SC1090 source "$ros_setup" if [[ -n "$workspace_setup" && -f "$workspace_setup" ]]; then # shellcheck disable=SC1090 source "$workspace_setup" fi ``` ```zsh # scripts/ros1_stop_target.sh:67-75 [[ -n "$state_file" ]] || { echo "[ERROR] --state-file is required" >&2; exit 2; } state_file="${state_file:A}" [[ -f "$state_file" ]] || { echo "[ERROR] state file not found: $state_file" >&2; exit 1; } # shellcheck disable=SC1090 source "$state_file" pid="${PID:-}" pgid="${PGID:-}" ros_home="${ROS_HOME:-}" ``` ### Technical Analysis Both lifecycle scripts accept an arbitrary path through `--state-file` and execute that file with the shell `source` built-in. A state file is therefore treated as executable code rather than inert metadata. The scripts only verify that the supplied path points to an existing file. They do not verify that: - The file was generated by `ros1_start_target.sh`. - The file is located beneath an approved state directory. - The file and its parent directories have trusted ownership and permissions. - The file contains only an allowlisted set of data assignments. - Values are free from shell substitutions, functions, redirections, or commands. Any shell statement in t ...[truncated 1899 chars]- Remediation
View remediation
