The vulnerability exists in the openclaw package's shell environment loading mechanism. The root cause is the lack of validation of the SHELL environment variable. The function resolveShell in src/infra/shell-env.ts would read the SHELL variable from the process environment and return it without checking if it pointed to a legitimate, trusted shell executable.
The value returned by resolveShell is then used by the execLoginShellEnvZero function, which executes the provided shell path to load environment variables. This creates a command injection vulnerability. If an attacker can control the SHELL environment variable in the context where the openclaw application is started, they can point it to a malicious binary, which will then be executed by execLoginShellEnvZero.
The entry point for this vulnerable logic is the loadShellEnvFallback function, which is exported and used by other parts of the application. The fix involves introducing a new function, isTrustedShellPath, which validates the shell path against a list of trusted prefixes and checks if it's listed in /etc/shells. The resolveShell function was updated to use this validation, falling back to a safe default (/bin/sh) if the validation fails. Additional defense-in-depth measures were also added to block SHELL from being overridden through the application's configuration.