Mar 4, 2026·6 min read·1 visit
OpenClaw's command validator only checked the primary executable name, ignoring arguments. Attackers could bypass the allowlist by passing malicious payloads as arguments to permitted wrappers like `/usr/bin/env` or `/bin/bash`.
A critical protection mechanism failure in OpenClaw's execution allowlist logic allowed attackers to bypass security restrictions by nesting malicious commands inside permitted wrapper binaries. By failing to recursively analyze command arguments, the system permitted arbitrary code execution if a wrapper like 'env' or 'bash' was present in the allowed list.
OpenClaw, an open-source multi-channel AI gateway, implements an "exec approvals" and "allowlist" system designed to restrict which binaries the platform can execute on the host machine. This mechanism is critical for preventing the AI agent from performing unauthorized system operations or executing arbitrary code.
The vulnerability, identified as GHSA-JJ82-76V6-933R, resides in the logic used to validate these execution requests. The system performed a "shallow" analysis, validating only the primary executable (the first element of the command array) against the defined policy. It failed to inspect subsequent arguments, which is a critical oversight when dealing with wrapper binaries or shell dispatchers.
This flaw allows an attacker to "smuggle" unauthorized commands through the allowlist. If the policy permits a generic wrapper—such as /usr/bin/env, bash, or powershell—an attacker can invoke that permitted binary and pass a malicious payload as an argument. The system correctly identifies the wrapper as allowed but unknowingly executes the hidden payload, resulting in a complete bypass of the execution sandbox.
The root cause of this vulnerability is CWE-693: Protection Mechanism Failure, specifically stemming from CWE-20: Improper Input Validation within the resolveCommandResolutionFromArgv function.
Prior to version 2026.2.23, OpenClaw's validation logic operated on a simple premise: if argv[0] is in the safeBins list, the execution is safe. This logic ignores the operational semantics of command-line utilities. Many binaries, particularly shells and environment setters, are designed specifically to execute other programs defined in their arguments.
env VectorThe /usr/bin/env utility is a prime example of this vector. Its primary purpose is to run a command in a modified environment. When OpenClaw receives a command array like ['/usr/bin/env', 'sh', '-c', 'malicious_script'], the validator only inspects index 0 (/usr/bin/env). If env is whitelisted (a common configuration for setting up runtime environments), the check passes. The operating system then executes env, which immediately hands control over to sh, executing the malicious script. The allowlist is effectively rendered moot because the security boundary does not extend to the semantic payload of the command.
The remediation involved a significant architectural change to how commands are resolved before validation. The fix was implemented in commit 2b63592be57782c8946e521bc81286933f0f99c7.
The vulnerable logic roughly resembled this simplified flow:
// Vulnerable Logic
function validate(argv: string[]) {
const executable = argv[0];
if (allowlist.includes(executable)) {
return true; // Vulnerable: Returns true without checking argv[1..n]
}
return false;
}The patch introduces a recursive unwrapper, unwrapDispatchWrappersForResolution, which "peels" back layers of known dispatchers to find the effective executable. This logic is implemented in both TypeScript and Swift.
// Patched Logic (Conceptual)
function unwrapDispatchWrappersForResolution(argv: string[], depth = 0): string[] {
// 1. Recursion limit to prevent DOS
if (depth > 4) return argv;
const cmd = argv[0];
// 2. Check if the command is a known wrapper (env, bash, sh, etc.)
if (isWrapper(cmd)) {
// 3. Parse arguments to find the next command in the chain
// e.g., for "env VAR=VAL cmd", skip VAR=VAL to find "cmd"
const nextCommand = parseWrapperArgs(argv);
// 4. Recursively resolve the next command
return unwrapDispatchWrappersForResolution(nextCommand, depth + 1);
}
return argv;
}The fix explicitly handles a wide range of shells (bash, zsh, fish, powershell, cmd.exe) and the env utility. It parses flags like -c (execute string) and handles environment variable assignments in env calls to locate the true target binary.
To exploit this vulnerability, an attacker requires the ability to trigger a command execution flow, such as through a system.run tool call or an authenticated API request to the Gateway. The attack relies on the presence of a "living off the land" binary in the allowlist.
/usr/bin/env or a shell like /bin/bash is present in the safeBins allowlist.Example Payload:
{
"tool": "system.run",
"args": [
"/usr/bin/env", // Allowed binary
"python3", // Forbidden binary (smuggled)
"-c",
"import os; os.system('cat /etc/passwd')"
]
}/usr/bin/env, approves the request, and spawns the process. env then executes python3, which executes the Python code, effectively bypassing the restriction on python3.> [!NOTE]
> This technique is effective even against strict allowlists if any dispatcher is permitted. A common misconfiguration is allowing bash to run legitimate maintenance scripts, which inadvertently opens the door to arbitrary script execution via bash -c.
The impact of this vulnerability is Remote Code Execution (RCE), dependent on the contents of the allowlist. While the CVSS score is 6.6 (Medium/High) due to the requirement of an allowed wrapper, the practical impact in default or common configurations is critical.
Confidentiality: An attacker can read sensitive files (SSH keys, configuration secrets) accessible to the OpenClaw process user. Integrity: An attacker can modify system files, install persistence mechanisms, or alter the behavior of the AI agent. Availability: An attacker can crash the service or consume system resources (e.g., fork bombs).
Since OpenClaw often runs with access to internal networks or sensitive data APIs, a breach here can serve as a pivot point for lateral movement within the infrastructure.
Users must upgrade to OpenClaw version 2026.2.23 or later immediately. The patch implements the recursive logic necessary to inspect nested commands.
Even with the patch, relying on software logic to parse complex shell arguments can be fragile. Administrators should adopt a "Defense in Depth" approach:
env, bash, sh, cmd.exe) from safeBins. Only allowlist specific, single-purpose binaries.openclaw security audit command available in the patched version.> [!WARNING]
> The patch has a known limitation: it only recurses 4 levels deep. Extremely complex nested chains (e.g., env env env env env cmd) might still theoretically bypass the check, although this is an edge case. Strict allowlisting remains the most robust defense.
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H| Product | Affected Versions | Fixed Version |
|---|---|---|
OpenClaw OpenClaw | <= 2026.2.22 | 2026.2.23 |
| Attribute | Detail |
|---|---|
| Vulnerability Type | Protection Mechanism Failure |
| CWE IDs | CWE-693, CWE-20 |
| CVSS v3.1 | 6.6 (Medium/High) |
| Attack Vector | Local / Remote (via API) |
| Exploit Maturity | Proof of Concept Available |
| Fixed Version | 2026.2.23 |
Protection Mechanism Failure