The vulnerability lies in the OpenClaw CLI's process cleanup mechanism, which could terminate processes not owned by the OpenClaw agent. This was due to the use of broad, pattern-based process killing commands without verifying process ownership. The analysis of the provided patches pinpoints the exact functions responsible for this behavior and the changes made to mitigate the risk.
The two vulnerable functions identified are cleanupResumeProcesses and cleanupSuspendedCliProcesses located in src/agents/cli-runner/helpers.ts.
In its vulnerable state, cleanupResumeProcesses used pkill -f to find and kill processes. This command kills any process whose command line matches the provided pattern, regardless of which user or parent process spawned it. On a multi-user system or a system with many processes, this could easily lead to terminating critical, unrelated processes.
Similarly, cleanupSuspendedCliProcesses would parse the output of the ps command to find suspended processes matching a certain command pattern. However, it failed to check the parent process ID (PPID). Without this check, it was possible to kill a suspended process belonging to another user or application that happened to match the command pattern.
The fix, as seen in commit 6084d13b956119e3cf95daaf9a1cae1670ea3557, addresses this by modifying both functions to fetch the PPID along with other process information. A check is then performed to ensure that the PPID of the process to be killed matches the PID of the current OpenClaw process (process.pid). This ensures that only direct child processes are terminated.
Further hardening was done in commit eb60e2e1b213740c3c587a7ba4dbf10da620ca66 to prefer a graceful SIGTERM before resorting to SIGKILL, and to improve the command-line matching logic to prevent false positives from substring matches. These changes, while not fixing the core ownership vulnerability, represent good practice in process management.