/

CVE-2026-28391

Severity:

CRITICAL RISK

(9.8)

OS Command Injection in OpenClaw Exec Allowlist

CVE-2026-28391

Modified

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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.exe invocations 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.exe command 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.exe interprets 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.exe when 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.exe metacharacters (&, |, >, <, ^, %, &&, ||, () 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.exe or 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 /c followed 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).

Sources

SourceLink
github.comgithub.com/openclaw/openclaw/commit/a7f4a53ce80c98ba1452eb90802d447fca9bf3d6
github.comgithub.com/openclaw/openclaw/security/advisories/GHSA-qj77-c3c8-9c3q
vulncheck.comvulncheck.com/advisories/openclaw-command-injection-via-cmdexe-parsing-bypass-in-allowlist-enforcement

Frequently asked

questions

Yes. If an OpenClaw deployment exposes the allowlist-gated exec functionality over the network, a remote attacker who can send crafted requests to that interface may exploit the flaw, subject to any authentication or access controls in place.

The attacker needs the ability to submit or influence allowlist-gated exec requests. In some deployments this may require valid credentials or specific roles, while in others it may be available to broader user groups or integrated services. The commands ultimately execute with the privileges of the OpenClaw service account on the Windows host.

The most robust fix is to stop building shell command strings from user-controlled input. Instead, invoke specific executables directly with validated, strongly typed parameters and avoid cmd.exe where possible. Complement this with argument-aware allowlisting and comprehensive rejection of shell metacharacters in any remaining dynamic fields.

Preventive measures include adopting secure coding patterns that avoid shell invocation, enforcing strict input validation and encoding rules, and embedding security checks into design and code review processes. Automated scanning for CWE-78 patterns, combined with least-privilege service accounts and conservative defaults for execution features, helps catch command injection risks early in the development lifecycle.

Find out what's already
exploitable in your codebase.