OpenClaw Environment Variable Override Vulnerability Allowing Arbitrary Code Execution
Vulnerability
A vulnerability in OpenClaw versions prior to 2026.3.31 allows workspace .env files to override the OPENCLAW_BUNDLED_HOOKS_DIR environment variable. This oversight enables the loading of attacker-controlled hook code. Exploitation involves replacing trusted default-on bundled hooks with untrusted ones from the workspace, potentially leading to the execution of arbitrary code.
Impact
Exploitation of this vulnerability could result in the execution of arbitrary code, facilitated by the execution of malicious hooks loaded from the workspace.
Reproduction
To reproduce this vulnerability, create a workspace .env file that includes a directive to override the OPENCLAW_BUNDLED_HOOKS_DIR variable with a path to custom hook code. When OpenClaw is launched, it will load the specified hooks from the untrusted workspace, replacing the default ones. This can be verified by checking if the overridden hooks are executed, potentially leading to arbitrary code execution.
Remediation
Users can update to OpenClaw version 2026.3.31 or later, where this vulnerability has been patched.
Vulnerability Rating
Our algorithm analyzes dozens of metrics to generate these 8 key vulnerability categories, which are then combined to calculate the overall risk score.
