T09 · Insecure Skill Coding Practices
- Location
scripts/radio.sh:65- Finding
Unvalidated Persisted PID Allows Signaling of Unrelated Processes
- Content
View full analysis
/dev/null } ``` ```bash stop_playback() { refresh_prefs if pid_is_running "$current_pid"; then kill "$current_pid" 2>/dev/null || true wait "$current_pid" 2>/dev/null || true fi prefs_json="$(jq '.current_pid = null | .paused = false' <<< "$prefs_json")" persist_prefs } ``` ```bash cmd_pause() { local signal state refresh_prefs if ! pid_is_running "$current_pid"; then prefs_json="$(jq '.current_pid = null | .paused = false' <<< "$prefs_json")" persist_prefs echo "Nothing playing." return 0 fi if [[ "$paused" == "true" ]]; then signal="CONT" state="resumed" prefs_json="$(jq '.paused = false' <<< "$prefs_json")" else signal="STOP" state="paused" prefs_json="$(jq '.paused = true' <<< "$prefs_json")" fi kill "-SIG$signal" "$current_pid" 2>/dev/null || { echo "Pause/resume is not supported for the current player on this platform." return 1 } persist_prefs echo "Playback $state." } ``` ### Technical Analysis The skill stores the media player's process ID in `preferences.json` and later trusts that value when stopping, pausing, or resuming playback. The `pid_is_running` function only uses `kill -0` to determine whether any process currently has that PID. It does not establish that the process is the `mpv` or `ffplay` instance originally launched by the skill. Process IDs are reused by operating systems. If the player exits without the preferences being updated, the saved PID can subsequently be assigned to an unrelated process. The next `stop`, `pause`, or `play` operation can then send `TERM`, `STOP`, or `CONT` to that process. Th ...[truncated 1987 chars]- Remediation
View remediation
