The vulnerability stems from two distinct issues related to unsafe handling of the PATH environment variable, leading to command hijacking. The analysis of the provided patch (013e8f6b3be3333a229a066eef26a45fec47ffcc) reveals the exact functions responsible.
-
Remote Command Hijacking: The function sanitizeEnv in src/node-host/invoke.ts improperly handled PATH overrides from remote callers. It contained logic that allowed certain modifications to the PATH variable. An attacker could exploit this to prepend a path to a malicious binary, causing subsequent command executions within the Node Host to be hijacked. The patch rectifies this by completely ignoring any PATH overrides from remote requests.
-
Local Command Hijacking: The function ensureOpenClawCliOnPath in src/infra/path-env.ts was designed to make the openclaw CLI accessible by modifying the PATH. It did so by prepending the node_modules/.bin directory of the current working directory to the system's PATH. When a user executed openclaw within a malicious repository, this feature could be abused to execute a counterfeit openclaw script or any other command placed in that directory. The patch addresses this by making this feature opt-in and changing the behavior from prepending to appending, which is a safer default.
Functions like createAcpClient in src/acp/client.ts were part of the vulnerable execution flow as they called ensureOpenClawCliOnPath and then used spawn to run a command, making them susceptible to the PATH manipulation.
In summary, the identified functions (sanitizeEnv, ensureOpenClawCliOnPath, createAcpClient) are the key runtime indicators of this vulnerability. Monitoring their execution, especially with untrusted inputs or in untrusted environments, would be critical for detecting exploitation attempts.