Apr 26, 2026·4 min read·37 visits
Untrusted workspace `.env` files can override OpenClaw internal variables, leading to arbitrary code execution. Users must upgrade to version 2026.4.20.
OpenClaw versions prior to 2026.4.20 are vulnerable to arbitrary code execution due to insecure handling of workspace-local `.env` files. The application fails to restrict the entire `OPENCLAW_` namespace, allowing untrusted repositories to override critical internal control variables.
OpenClaw is an AI-driven personal assistant and coding tool distributed via the npm package registry. The application supports loading workspace-specific configuration data through local .env files. This functionality allows users to customize runtime behavior on a per-project basis.
A vulnerability exists in OpenClaw versions prior to 2026.4.20 regarding the validation of these environment variables. The application fails to adequately sanitize the runtime environment when loading variables from an untrusted workspace.
Attackers can exploit this flaw by supplying a malicious repository containing a crafted .env file. When a user opens the repository with OpenClaw, the application applies the attacker-controlled variables. This configuration override facilitates arbitrary code execution within the context of the user running OpenClaw.
The root cause resides in the environment variable loading implementation located within src/infra/dotenv.ts. The application implements a security control to prevent untrusted workspaces from modifying sensitive configuration values. This control relies on a denylist of variable prefixes defined in the BLOCKED_WORKSPACE_DOTENV_PREFIXES array.
The original implementation successfully blocked specific sub-namespaces, such as OPENCLAW_CLAWHUB_, OPENCLAW_DISABLE_, and OPENCLAW_SKIP_. However, the logic omitted the generic OPENCLAW_ prefix from the denylist. This omission created a validation bypass for any variable beginning with OPENCLAW_ that did not match the explicitly blocked sub-strings.
Consequently, an untrusted workspace .env file could define arbitrary internal control variables. The application would import these variables into its runtime configuration, granting external control over internal application states. This oversight effectively allowed attackers to manipulate paths, API endpoints, and execution hooks utilized by OpenClaw.
The vulnerability is evident in the configuration of the BLOCKED_WORKSPACE_DOTENV_PREFIXES array prior to version 2026.4.20. The array specified explicit variable strings to reject during the .env loading process.
// src/infra/dotenv.ts (Vulnerable Implementation)
const BLOCKED_WORKSPACE_DOTENV_PREFIXES = [
"ANTHROPIC_API_KEY_",
"CLAWHUB_",
"OPENAI_API_KEY_",
"OPENCLAW_CLAWHUB_",
"OPENCLAW_DISABLE_",
"OPENCLAW_SKIP_",
];The fix introduced in commit 018494fa3ebb9145112e68b56fe1cb2e9f9a9ed6 modifies the array to include the base namespace. By appending the root prefix, the application correctly adopts a fail-closed approach for all internal runtime variables.
// src/infra/dotenv.ts (Patched Implementation)
const BLOCKED_WORKSPACE_DOTENV_PREFIXES = [
"ANTHROPIC_API_KEY_",
"CLAWHUB_",
"OPENAI_API_KEY_",
"OPENCLAW_",
"OPENCLAW_CLAWHUB_",
"OPENCLAW_DISABLE_",
"OPENCLAW_SKIP_",
];This patch ensures that any workspace variable starting with OPENCLAW_ is explicitly ignored. System-level and globally trusted environment variables remain unaffected, successfully restricting control of the OPENCLAW_ namespace to authorized scopes.
Exploitation requires user interaction. The attacker must construct a malicious repository containing a .env file engineered to override internal application variables. A common payload targets the OPENCLAW_GIT_DIR variable to redirect version control operations to an attacker-controlled directory.
# Malicious .env payload
OPENCLAW_GIT_DIR=/tmp/attacker_controlled_git
OPENCLAW_WORKSPACE_DIR=/tmp/malicious_payloadsWhen the victim opens this repository using OpenClaw, the vulnerable dotenv.ts logic imports these variables into the application context. Subsequent operations performed by OpenClaw, such as updating plugins or pulling repository data, will utilize the poisoned OPENCLAW_GIT_DIR path.
If the attacker provisions the target directory with malicious git hooks or executable binaries, OpenClaw will execute them automatically. This results in arbitrary code execution operating under the privileges of the victim user.
The primary impact of this vulnerability is arbitrary code execution. An attacker successfully exploiting this flaw gains the ability to execute OS-level commands on the host machine. This execution occurs silently during standard application operation.
The attacker inherits the privileges of the user running the OpenClaw process. This access allows the exfiltration of sensitive local data, including ssh keys, environment variables, and authentication tokens stored on the filesystem. The attacker can also establish persistence through standard local mechanisms.
Due to the localized nature of the attack, external network exploitation without user interaction is not feasible. The attack strictly relies on social engineering or supply-chain contamination to deliver the malicious workspace to the victim machine.
The maintainers of OpenClaw addressed this vulnerability in version 2026.4.20. Users must update their installations to this version or later to eliminate the vulnerability. The patch correctly secures the runtime variable namespace.
If immediate upgrading is unfeasible, users must avoid opening untrusted workspaces with OpenClaw. Manual inspection of a repository's .env file prior to execution provides an effective interim mitigation. Users should specifically look for variables attempting to declare the OPENCLAW_ prefix.
Organizations utilizing OpenClaw in automated pipelines should restrict workspace processing to verified, internal repositories. Security scanning tools can be configured to detect malicious .env declarations dynamically during the CI/CD initialization phases.
| Product | Affected Versions | Fixed Version |
|---|---|---|
openclaw OpenClaw | < 2026.4.20 | 2026.4.20 |
| Attribute | Detail |
|---|---|
| Attack Vector | Local / User Interaction |
| Impact | Arbitrary Code Execution |
| CWE ID | CWE-829 |
| Exploit Status | Proof of Concept |
| Patched Version | 2026.4.20 |
Inclusion of Functionality from Untrusted Control Sphere
A path traversal vulnerability (CWE-22) in termux-sync prior to version 1.2.4 allows an attacker to overwrite arbitrary files within the Termux environment during the backup restoration process. The flaw stems from the application trusting attacker-controlled extraction paths defined in the backup's manifest.json file, failing to validate archive members against directory traversal sequences during tar extraction, and using unsanitized backup names when constructing temporary directories. If a user restores a malicious backup archive from local storage, shared folders, GitHub, or Google Drive, an attacker can overwrite sensitive configuration files such as shell startup scripts or local binaries, resulting in arbitrary code execution under the privileges of the Termux user.
SpamScope mail-parser versions 3.8.0 prior to 4.6.0 contain a path traversal vulnerability (CWE-22) within the write_attachments() and write_sample() functions. The library passes untrusted attachment filenames directly into os.path.join() without stripping directory components, validating path containment, or verifying symbolic links. An attacker can send a crafted email containing relative path traversal sequences or absolute filesystem paths in the Content-Disposition header to write or overwrite arbitrary files accessible to the parsing process.
A Regular Expression Denial of Service (ReDoS) vulnerability exists in SpamScope mail-parser versions 4.2.0 prior to 4.6.1. Two separate regular expressions evaluated during standard email header parsing exhibit quadratic to cubic backtracking complexity when processing headers padded with whitespace or angle brackets. An unauthenticated remote attacker can exploit this flaw by sending a small, RFC-compliant email message, causing parsing worker threads or processes to stall at 100% CPU utilization for extended periods.
CVE-2026-129297 is an origin validation vulnerability (CWE-345) in the Python library mail-parser prior to version 4.6.2. The MailParser.get_server_ipaddress() method fails to properly isolate MTA-recorded client IP addresses from sender-controlled text within email Received headers. Due to naive substring delimiter matching, appearance-based regular expression scanning, and fail-open header traversal, remote attackers can spoof their originating IP address to bypass email security controls, blocklists, and anti-spam attribution.
CVE-2026-129299 (GHSA-24mq-4vc6-2prf) is a parsing and serialization flaw in SpamScope mail-parser prior to version 4.6.2. The library uses reflective Python attribute resolution (getattr) over untrusted email header names and applies caller convenience transformations (such as underscore-to-hyphen folding and _json/_raw suffix stripping) directly to wire headers. An unauthenticated remote attacker can send crafted emails that trigger uncaught TypeError exceptions during JSON serialization or cause security-relevant headers and body content to be silently dropped without setting defect indicators.
CVE-2026-129236 is a command-line argument injection vulnerability (CWE-88) in Kubeshark, an eBPF-based network observability tool for Kubernetes. Located within the Model Context Protocol (MCP) server implementation in cmd/mcpRunner.go, the flaw occurs when handling the start_kubeshark tool request. When the MCP server runs with the --allow-destructive flag, the callStartKubeshark function appends the caller-supplied pod_regex parameter directly to the kubeshark tap argument slice without an end-of-options (--) delimiter. Because Kubeshark uses the Cobra and pflag libraries for command-line parsing, any pod_regex value prefixed with a hyphen is interpreted as a CLI flag rather than a positional regular expression. An attacker capable of influencing MCP tool arguments, such as through indirect prompt injection against a connected Large Language Model (LLM) agent, can inject the --set flag to override Helm chart values like tap.docker.registry. Because Kubeshark deploys its worker DaemonSet with privileged security contexts and host networking enabled, redirecting the container image registry allows arbitrary code execution as root across all Kubernetes cluster nodes.