OpenClaw Workspace .env Hook Override Vulnerability
The openclaw package is vulnerable to a high severity issue where a workspace's `.env` file can override the `OPENCLAW_BUNDLED_HOOKS_DIR`, allowing attackers to replace trusted hooks with malicious code.
Triage facts
Revision 2- Evidence
- Unknown
- Severity
- High
- Sources
- 1 public source
- Freshness
- Revision 2Apr 2, 21:00 UTC
- Detection
- 2 rules
Revision history 1 entry · Revision 2
- Revision 2
Repaired a legacy canonical identity collision
Changed: slug
The openclaw package, a yet-to-be-defined tool, is vulnerable to a critical flaw affecting versions 2026.3.28 and earlier. This vulnerability stems from the application's susceptibility to having its default hook directory, designated by the OPENCLAW_BUNDLED_HOOKS_DIR environment variable, overridden by settings defined within a workspace's .env file. An attacker could leverage this vulnerability within an untrusted workspace to replace trusted, default-on bundled hooks with malicious code. Version 2026.3.31 resolves this issue. This vulnerability was reported by @nexrin.
Attack Chain
- An attacker gains access to or creates a workspace where OpenClaw is used.
- The attacker crafts a malicious
.envfile within the workspace. - The malicious
.envfile definesOPENCLAW_BUNDLED_HOOKS_DIRand sets it to a directory controlled by the attacker. - The attacker places malicious hook scripts (e.g., JavaScript, Python, or shell scripts) within the attacker-controlled directory. These scripts are designed to execute arbitrary code.
- When OpenClaw initializes within the workspace, it reads the
.envfile and uses the attacker-controlled directory as the location for bundled hooks, instead of the intended secure location. - OpenClaw executes the malicious hook scripts as part of its normal operation.
- The attacker achieves code execution within the context of the OpenClaw process.
- The attacker leverages the code execution to establish persistence or escalate privileges on the affected system.
Impact
Successful exploitation of this vulnerability allows an attacker to execute arbitrary code within the context of the OpenClaw application. Depending on how OpenClaw is implemented and the privileges it operates with, this could lead to complete system compromise. This could impact any environment where OpenClaw is used to manage or automate tasks within workspaces.
Recommendation
- Upgrade the
openclawpackage to version 2026.3.31 or later to patch the vulnerability. - Monitor for modifications to
.envfiles within OpenClaw workspaces, looking for changes to theOPENCLAW_BUNDLED_HOOKS_DIRenvironment variable. Deploy the "Detect OpenClaw Bundled Hooks Override via .env" Sigma rule to detect this. - Implement strict access controls on OpenClaw workspaces to prevent unauthorized users from modifying
.envfiles.
Detection coverage 2
Detect OpenClaw Bundled Hooks Override via .env
highDetects modifications to .env files that override the OPENCLAW_BUNDLED_HOOKS_DIR environment variable, indicating a potential hook injection attempt.
Detect Execution from Non-Standard OpenClaw Hook Directory
mediumDetects execution of scripts or binaries from a directory specified by OPENCLAW_BUNDLED_HOOKS_DIR in the .env file, indicating a potential hook injection attempt.
Detection queries are available on the platform. Get full rules →