Summary
OpenClaw versions prior to 2026.2.19 contain a command injection vulnerability in the Lobster extension tool execution path, where a Windows shell fallback is used with shell: true after a subprocess spawn failure.
By injecting shell metacharacters into command arguments that are later passed to this fallback, an attacker can execute arbitrary commands on the host when subprocess launch fails with specific errors.
Affected context
This vulnerability appears in OpenClaw's Lobster extension mechanism when external tools are invoked from the application.
It is most relevant on Windows environments where, after a failed spawn (e.g., EINVAL or ENOENT), the code falls back to a shell-based invocation with shell: true.
The risk is elevated when user-controlled or untrusted data can influence the command arguments passed into this fallback path, particularly in workflows that trigger external tooling or plugins.
Exploit preconditions
- Attack surface: The Lobster extension tool-execution interface, typically triggered when OpenClaw runs external tools or helper processes.
- Required access: Ability to supply or influence command arguments (e.g., via project configuration, plugin parameters, or user input that flows into tool invocation).
- Trigger point: A subprocess launch that fails with
EINVALorENOENT, causing the code to fall back to Windows shell execution withshell: true. - Why exploitation is possible: The shell fallback passes unvalidated arguments to the Windows shell, allowing shell metacharacters to be interpreted as additional commands rather than harmless data.
Why this happens
The underlying issue stems from treating untrusted command arguments as safe when constructing shell commands for a fallback execution path.
When the initial spawn call fails with EINVAL or ENOENT, the implementation switches to using the Windows shell with shell: true, effectively concatenating arguments into a shell command line.
This maps directly to CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), because user-controllable input is not properly escaped or passed as strict arguments, allowing shell metacharacters to alter command structure and behavior.
Potential impact
- Execution of arbitrary OS commands under the context of the OpenClaw process.
- Reading, modifying, or deleting files accessible to the OpenClaw user account.
- Exfiltration or corruption of project data processed by OpenClaw.
- Establishment of persistence or lateral movement within the developer workstation or CI environment.
General mitigation guidance
Mitigation should focus on eliminating shell-based fallback paths for untrusted input and ensuring arguments are never interpreted by a shell when avoidable.
Recommended defensive patterns include:
- Prefer direct process invocation APIs that pass arguments as arrays without involving a shell, even on fallback paths.
- Avoid
shell: trueor equivalent flags for any command that contains user-influenced components. - Introduce strict validation and normalization of command arguments, rejecting or sanitizing characters with special meaning in the Windows shell (e.g.,
&,|,>,<,^). - Centralize command construction in a dedicated utility that enforces safe patterns and prohibits ad-hoc string concatenation.
- Run external tools with least-privilege accounts and limit file-system and network access where practical to reduce the blast radius if injection occurs.
How teams detect issues like this
Detection typically involves both code-centric and behavior-centric approaches:
- Static analysis: Define rules to flag uses of
shell: true(or similar shell-invoking APIs) combined with variables derived from configuration files, user input, or plugin parameters. - Code review signals: Pay attention to any error-handling paths that switch from safe
spawn-like APIs to shell-based execution, and scrutinize string concatenation when forming commands. - Configuration and policy enforcement: Establish internal guidelines disallowing shell invocation for dynamic commands in core tooling, enforced via CI checks or linters.
- Runtime monitoring: On sensitive hosts (developer workstations, CI runners), monitor for unexpected shell processes spawned by OpenClaw and alert on anomalous commands or destinations.

