/

CVE-2026-53822

Severity:

HIGH RISK

(8.8)

TOCTOU Command Injection (CWE-367) in OpenClaw Shell

CVE-2026-53822

Analyzed

Vulnerability type

Category:

Command Injection via Race Condition

CWE:

CWE-367, CWE-77

Impact:

Arbitrary Command Execution and Policy Bypass

Severity:

HIGH RISK

(8.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 contains a race-condition-based command injection issue where the shell wrapper's argument vector can change between allowlist approval and execution.

If an attacker can modify or rebuild the command arguments after validation, they may execute unapproved command shapes and bypass existing security controls.

Affected context

This vulnerability arises in deployments where OpenClaw uses a shell wrapper to validate and then execute commands based on an allowlist.

The affected context includes workflows where:

  • Command arguments are checked once and then executed later
  • The argv array or its backing storage can be modified between validation and execution
  • Multiple threads, processes, or hooks can mutate command arguments after approval

It is most relevant when users or other components can influence command arguments at runtime without additional integrity checks.

Exploit preconditions

  • Attack surface: Shell wrapper or helper programs that validate and then invoke external commands.
  • Required access: Ability to influence or control the command arguments (argv) after validation but before execution; typically local user or process-level access.
  • Trigger point: The time window between allowlist-based approval of argv and the actual exec of the shell command.
  • Why exploitation is possible: The design assumes argv remains stable after validation, but it can be modified, enabling a time-of-check to time-of-use (TOCTOU) mismatch that allows different command shapes to be executed than those originally approved.

Why this happens

The underlying bug stems from a time-of-check to time-of-use race condition (CWE-367) combined with shell command execution semantics.

OpenClaw performs security checks on a representation of the command arguments, but relies on mutable data structures (such as argv or equivalent buffers) that can be altered after validation.

Because the execution step trusts that the previously approved arguments are unchanged, attackers can mutate or rebuild argv in the interim, effectively injecting a new command shape that was never checked.

This pattern fits the broader class of command injection problems (CWE-77) where untrusted input influences shell execution, but is exacerbated by non-atomic validation and execution flows.

Potential impact

  • Attackers could execute arbitrary shell commands under the privileges of the OpenClaw process.
  • Security allowlists and command-shape policies could be bypassed, undermining enforced restrictions.
  • System integrity may be compromised through unauthorized configuration changes or file operations.
  • Downstream systems or pipelines relying on OpenClaw for command enforcement could be subverted.

General mitigation guidance

Effective mitigation focuses on making validation and execution atomic and minimizing the trust placed in mutable argument data.

Common defensive patterns include:

  • Constructing a separate, immutable command representation for execution after validation, rather than reusing mutable argv.
  • Avoiding shell interpretation where possible by using direct, parameterized system APIs that do not concatenate or re-parse strings.
  • Ensuring that no untrusted party can modify argument buffers or shared data structures between validation and use.
  • Applying least-privilege to the executing process so that, even if misused, its ability to affect the broader system is constrained.
  • Designing wrappers so that any late changes to inputs trigger re-validation or cause execution to fail closed.

How teams detect issues like this

Detection typically involves analyzing both code paths and runtime behavior for non-atomic validation and execution.

Useful strategies include:

  • Static analysis rules that flag sequences where security validation (e.g., allowlist checks) is separated from execution by intervening operations or shared mutable state.
  • Code review checklists that explicitly ask whether validated command arguments can be modified before exec calls.
  • Instrumentation or logging that records the approved command shape and the final executed command, enabling anomaly detection when they diverge.
  • Policy enforcement in CI/CD to prevent the introduction of shell wrappers that rely on mutable argv or shared buffers between check and use.

Sources

SourceLink
github.comgithub.com/openclaw/openclaw/security/advisories/GHSA-2j8v-hwgc-x698
vulncheck.comvulncheck.com/advisories/openclaw-command-argument-modification-via-shell-wrapper-between-approval-and-execution

Frequently asked

questions

It depends on how OpenClaw is exposed. If remote users can indirectly influence command arguments (for example, through APIs or jobs that invoke the shell wrapper), the issue can be triggered remotely; otherwise it may require local or internal access to modify argv.

An attacker must be able to affect the command arguments after they pass validation, which typically implies the ability to run or manipulate code in the same environment or to control an upstream component that mutates argv or shared buffers.

The most robust pattern is to decouple validation from mutable inputs: build an immutable, sanitized command structure at validation time and pass that structure directly to non-shell execution APIs, ensuring there is no window in which untrusted code can alter what will be executed.

Design security checks and critical uses to be atomic, avoid relying on shared mutable state between validation and execution, minimize use of shell interpreters, and incorporate explicit TOCTOU and command injection reviews into your secure coding and code-review practices.

Find out what's already
exploitable in your codebase.