T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/cleanup-zombie-browsers.sh:343
- Finding
- Unverified Process-Group Termination Can Kill Unrelated Processes<![CDATA[ ## Vulnerability Details **File Location**: `scripts/cleanup-zombie-browsers.sh`, lines 343–365 **Vulnerability Type**: `T09: Insecure Skill Coding Practices` **Risk Level**: High ### Vulnerable Code ```bash # SIGTERM the process group (kills main + all children) log "Sending SIGTERM to PID $pid (+ ~$child_count child processes)" kill -TERM -- "-$(ps -o pgid= -p "$pid" 2>/dev/null | tr -d ' ')" 2>/dev/null \ || kill -TERM "$pid" 2>/dev/null \ || { log "PID $pid already gone"; continue; } # Wait for graceful exit waited=0 while (( waited < GRACE_PERIOD_SECONDS )); do if ! kill -0 "$pid" 2>/dev/null; then log "PID $pid and children terminated gracefully" break fi sleep 1 waited=$((waited + 1)) done # SIGKILL if still alive if kill -0 "$pid" 2>/dev/null; then log "PID $pid did not exit after ${GRACE_PERIOD_SECONDS}s, sending SIGKILL" kill -KILL -- "-$(ps -o pgid= -p "$pid" 2>/dev/null | tr -d ' ')" 2>/dev/null \ || kill -KILL "$pid" 2>/dev/null || true fi ``` ### Technical Analysis A negative PID passed to `kill` addresses an entire process group rather than only the validated browser PID. The discovery logic validates one process as a current-user, orphaned OpenClaw browser, but the script does not enumerate or validate every member of that process group before sending SIGTERM or SIGKILL. Process-group membership does not guarantee that every member is a descendant of the selected browser or that every member satisfies the OpenClaw command-line, ownership, orphan-status, and age checks. Consequently, the destructive operation has a broader scope than the documented browser-only safety boundary. The `child_count` calculation does not mitigate this issue. It only counts direct children and is not used to constrain which processes receive the signal. ### Attack Path 1. A qualifying browser process is placed in, or remains part of, a process group that also contains unrelated processes. 2. The ...[truncated 1025 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Do not signal the entire process group based on validation of a single PID. 2. Signal only the validated PID and explicitly enumerated descendants. 3. Before signaling each descendant, verify: - The process is owned by the expected UID. - Its ancestry leads to the originally selected browser. - Its process start time matches the recorded value, preventing PID-reuse errors. 4. Immediately revalidate the root process before each destructive action. 5. If process-group signaling is operationally required, enumerate every group member and abort unless every member passes the intended safety policy. 6. Record which exact PIDs were validated and signaled rather than estimating the number of affected children. ]]>
