Summary
OpenClaw node-host system.run on macOS contains a command injection vulnerability where allowlist-based command restrictions can be bypassed using shell command substitution syntax.
By embedding malicious commands within double-quoted text that is improperly parsed, a remote attacker may execute arbitrary, non-allowlisted commands on the underlying system.
Affected context
This vulnerability affects OpenClaw deployments on macOS that use the node-host system.run capability to execute shell commands with an allowlist-based security control.
The issue manifests when user-controlled input is incorporated into shell command lines and evaluated by a shell that supports command substitution (e.g., $(...) or backticks) inside double-quoted strings.
Environments that accept remote or untrusted input to drive system commands, scripts, or job execution through system.run are at heightened risk.
Exploit preconditions
- Attack surface: Remote interfaces or APIs that expose OpenClaw node-host
system.runor any feature that indirectly triggers it. - Required access: Ability to supply or influence command arguments, script content, or parameters that are passed into
system.run. - Trigger point: Invocation of
system.runwhere the application constructs a shell command string that includes attacker-controlled data, then passes it to a shell for execution. - Why exploitation is possible: The allowlist validation focuses on top-level commands but does not correctly account for command substitution tokens inside double-quoted segments, allowing hidden commands to be interpreted and executed by the shell.
Why this happens
The root cause lies in improper neutralization of special elements used in operating system commands, mapped to CWE-78.
OpenClaw relies on an allowlist to limit which commands can be executed, but the parsing logic assumes that double-quoted content is safe and does not fully inspect or neutralize command substitution constructs like $(...) or backtick expressions.
When a shell interprets the constructed string, it performs command substitution before executing the main command, enabling attacker-supplied subcommands to run regardless of the allowlist.
Conceptually, this is an insecure pattern where user input is embedded into shell commands and validated as plain text, while the actual execution semantics are governed by the shell's parsing rules, not the application's allowlist logic.
Potential impact
- Execution of arbitrary commands that are not present in the intended allowlist
- Unauthorized access to local files, environment variables, and system configuration on the macOS host
- Lateral movement within the host environment or connected services accessible from that host
- Data exfiltration, tampering, or destruction of application and user data
- Installation of persistent malware or backdoors on the affected system
General mitigation guidance
Effective mitigation focuses on removing dependence on shell parsing and reducing the power of user-controlled input:
- Prefer direct process invocation APIs that accept command and arguments as structured arrays, avoiding intermediate shells and their substitution rules.
- Apply strict input validation and normalization, explicitly rejecting command substitution tokens (e.g.,
$(,`,${), pipes, and other meta-characters when user input must be used in commands. - Implement context-aware allowlists at the argument level, not just the top-level command, and validate every user-controlled segment against expected patterns.
- Run command-executing components under least-privilege accounts, restricting filesystem, network, and system capabilities to limit blast radius if exploitation occurs.
- Adopt a secure-by-default configuration, disabling or minimizing dynamic command execution features where they are not strictly necessary.
How teams detect issues like this
Detection can combine code-level analysis with runtime monitoring:
- Use static analysis or manual code review to locate all usages of
system.runor equivalent wrappers that build shell command strings, especially those that concatenate user-controlled variables. - Flag patterns that pass full command lines to
/bin/sh,/bin/bash, or similar shells, and that rely solely on allowlists without escaping or structural argument passing. - Introduce CI/CD checks that scan for command substitution tokens in templates, scripts, or code segments that construct shell commands using external input.
- Employ runtime logging around command execution paths, capturing the final command line and arguments for anomaly detection and to identify unexpected embedded subcommands.

