Summary
OpenClaw versions prior to 2026.2.2 contain an OS command injection flaw where Windows cmd.exe metacharacters are not fully validated in allowlist-gated exec requests under a non-default configuration.
Remote attackers can embed shell metacharacters such as & or %...% in approved command strings to bypass the allowlist and execute arbitrary, unapproved commands on the underlying system.
Affected context
This vulnerability appears in OpenClaw deployments that:
- Enable the non-default feature for allowlist-gated execution of Windows commands, and
- Invoke commands via
cmd.exe(or its semantics) on Windows hosts, and - Rely on an application-level allowlist to constrain which commands can be run.
In these contexts, OpenClaw performs partial validation of command strings, but does not reliably neutralize or reject Windows shell metacharacters that can change control flow or concatenate additional commands.
Exploit preconditions
- Attack surface: Network-exposed interfaces (e.g., HTTP APIs, RPC endpoints, or task runners) that accept command or action names and translate them into Windows
cmd.exeinvocations through OpenClaw. - Required access: Ability to submit or influence exec requests that are processed by the allowlist mechanism (this may be authenticated or unauthenticated depending on deployment).
- Trigger point: Construction of a
cmd.execommand line from an allowlisted base command and attacker-controlled parameters, with insufficient filtering of metacharacters. - Why exploitation is possible: The allowlist checks if the intended base command is allowed, but subsequent concatenation with shell metacharacters (such as
&,|,&&,||,%VAR%, or command substitution patterns) is not robustly sanitized.cmd.exeinterprets these characters as control operators, enabling the attacker to append additional, unapproved commands that run with the same privileges as OpenClaw.
Why this happens
The core issue is an OS command injection pattern (CWE-78), where untrusted input is passed to a command interpreter without complete neutralization of special characters.
OpenClaw attempts to enforce an allowlist of permissible operations, but its validation logic focuses on approved command names or prefixes rather than the full command string as interpreted by cmd.exe. When user-controlled segments are appended directly into a shell command, metacharacters such as & or %...% become active control symbols, allowing chaining or substitution of additional commands.
Conceptually, this is an insecure pattern where:
- The application uses the shell as a convenience wrapper instead of invoking specific binaries with argument arrays.
- Security checks are performed on a nominal command representation, not on the actual execution primitive seen by the shell.
- Metacharacters and command expansion features are not comprehensively escaped or rejected, causing the security boundary enforced by the allowlist to be bypassed.
Potential impact
- Remote attackers may execute arbitrary system commands beyond the allowlisted set.
- Compromise of the Windows host running OpenClaw, including installation of malware or backdoors.
- Access to sensitive configuration files, logs, and credentials available to the OpenClaw process.
- Lateral movement within the network by using the compromised host as a pivot point.
- Disruption of service availability through destructive commands (e.g., stopping services, deleting data).
- Escalation of impact if OpenClaw runs with elevated privileges or on critical infrastructure nodes.
General mitigation guidance
Effective mitigation focuses on removing dependence on shell interpretation and tightening the trust boundary around command execution:
- Prefer direct process invocation (e.g., using parameterized APIs or process-builder abstractions) instead of routing operations through
cmd.exewhen possible. - Treat all user-supplied or externally sourced command fragments as untrusted and avoid concatenating them into shell command strings.
- If shell usage cannot be eliminated, implement strict input validation that:
- Rejects or escapes all
cmd.exemetacharacters (&,|,>,<,^,%,&&,||,()and similar constructs). - Enforces a strongly typed command schema (e.g., selecting an action from an enum and providing constrained arguments).
- Design allowlist policies to be argument-aware, not just command-name aware, so that only well-formed, fully validated command invocations are permitted.
- Run OpenClaw and related execution components with least privilege, restricting filesystem, network, and process privileges to limit damage if command injection occurs.
- Introduce configuration defaults that disable or minimize dynamic exec capabilities, requiring explicit opt-in for higher-risk features.
How teams detect issues like this
Detection involves both code-level inspection and runtime monitoring:
- Static analysis and code review:
- Flag any code paths where untrusted input is concatenated into strings passed to
cmd.exeor generic shell execution APIs. - Look for security checks that validate only command prefixes or names, without analyzing the full command line that reaches the shell.
- Identify incomplete blacklists (e.g., checking for a few bad characters) instead of robust allowlists or structured argument handling.
- Security testing and fuzzing:
- Include tests that inject common Windows shell metacharacters into parameters used by the exec allowlist feature.
- Use automated security scanners that specialize in command injection to probe exposed API endpoints.
- Runtime/operational monitoring:
- Monitor process creation logs for unexpected command patterns spawned by OpenClaw (e.g.,
cmd.exe /cfollowed by atypical commands). - Implement host-based intrusion detection rules to alert on suspicious command sequences or known abuse patterns.
- Policy and CI integration:
- Enforce secure coding guidelines that disallow direct use of shell-based executors in new code.
- Integrate static analysis tools into CI pipelines with rules for OS command injection patterns (CWE-78).

