Summary
OpenClaw releases before 2026.2.22 inherit HOME and ZDOTDIR directly into the system.run shell startup phase, enabling malicious startup scripts to run before command allowlist checks occur.
Attackers who can influence these environment variables can execute arbitrary code by planting crafted initialization files, effectively neutralizing the intended command restrictions.
Affected context
The flaw materializes when OpenClaw deployments use system.run to execute shell commands while trusting user-controlled HOME or ZDOTDIR values.
Environments that permit remote users to set or override startup paths, or that source shared file systems for shell configuration files, inherit untrusted shell scripts before the allowlist is enforced.
Exploit preconditions
- Attack surface: Remote invocation of system.run-driven shell sessions
- Required access: Ability to set HOME/ZDOTDIR or write startup files (.bash_profile, .zshenv) reachable by the invoked shell
- Trigger point: Shell initialization executed prior to allowlisted command evaluation
- Why exploitation is possible: system.run fails to sanitize or override critical environment variables, so untrusted init files execute immediately
Why this happens
The system.run implementation spawns shells that implicitly source initialization files from HOME/ZDOTDIR without validation.
This design aligns with CWE-78 because untrusted environment data directs command evaluation logic, allowing attacker-controlled scripts to run.
Potential impact
- Arbitrary command execution under the OpenClaw runtime context
- Bypass of administrative allowlists or policy-enforced command sets
- Installation of persistence mechanisms via malicious shell profiles
General mitigation guidance
- Normalize shell startup variables before process creation, forcing known-safe HOME/ZDOTDIR paths.
- Launch shells with restrictive profiles or disable sourcing of user-provided init files.
- Apply strict privilege separation so that even if initialization runs, it executes with minimal capabilities.
- Treat environment inputs as untrusted and validate them prior to invoking helper binaries or shells.
How teams detect issues like this
- Static analysis for shell invocations that inherit unsanitized environment variables.
- Code review checklists calling out reliance on HOME/ZDOTDIR or other shell init locations.
- Runtime policy enforcement and audit hooks that flag unexpected profile sourcing or startup script modifications.
- Continuous monitoring tools can watch for unexpected .bash_profile/.zshenv creations near OpenClaw workloads.

