The vulnerability, identified as GHSA-4685-c5cp-vp95, is a bypass of the safeBins execution protection in OpenClaw. The safeBins feature is intended to allow only a limited set of command-line tools to run with input from stdin, preventing them from accessing the filesystem. The root cause of the vulnerability was an incomplete implementation of the isSafeBinUsage function in src/infra/exec-approvals-allowlist.ts. This function was responsible for validating whether a command was safe to execute.
The analysis of the patch cfe8457a0f4aae5324daec261d3b0aad1461a4bc reveals that the isSafeBinUsage function did not check for specific command-line flags that could escalate the privileges of the executed command. For example, the sort command could be executed with the -o or --output flag to write to an arbitrary file, and the grep command could be used with recursive flags (-r, -R) to read files from the filesystem.
The patch addresses this by introducing a new function, hasBlockedSafeBinOption, which checks the arguments of a command against a blocklist of dangerous flags for each safe binary. This new check is integrated into the isSafeBinUsage function, effectively closing the bypass. The patch also removes sort and grep from the default list of safe binaries as an additional hardening measure. Therefore, the isSafeBinUsage function is the primary vulnerable function, as it contained the flawed logic that permitted the bypass.