NewApp Monitoring is liveSign up free
AgentbeamBeta
AI agent vulnerability · OpenClaw

CVE-2026-41336: OpenClaw: Workspace `.env` can override the bundled hooks root and load attacker hook code

highCVSS 4.0 8.5 · 3.1 7.8GHSA-3qpv-xf3v-mm45

OpenClaw 2026.3.28 and earlier load a workspace .env file that can set OPENCLAW_BUNDLED_HOOKS_DIR. A malicious repository can point that variable at its own directory, so OpenClaw loads attacker hook code in place of the trusted bundled hooks and runs it. Upgrade to openclaw 2026.3.31.

Published Apr 2, 2026 · Updated May 6, 2026 · Analysis Oct 30, 2026

What an attacker can do

OpenClaw reads a .env file from the workspace you open. It keeps a blocklist of keys a workspace .env may not set, in BLOCKED_WORKSPACE_DOTENV_KEYS (src/infra/dotenv.ts). OPENCLAW_BUNDLED_PLUGINS_DIR was on the list. OPENCLAW_BUNDLED_HOOKS_DIR and OPENCLAW_BUNDLED_SKILLS_DIR were not. Bundled hooks are on by default and trusted, so a variable that moves their root changes which code runs.

The attacker needs a repository or workspace you open with OpenClaw: a cloned project, a downloaded archive or a shared folder. It holds a .env with OPENCLAW_BUNDLED_HOOKS_DIR set to a path inside the repo, for example ./attacker-hooks, and hook code in that folder. When you start OpenClaw there, it loads those hooks in place of the bundled ones, and they run with your user's rights. That means code execution, access to your files and tokens, and a foothold for further actions by the agent. The CVSS vector marks it as local with user interaction, which is the act of opening the workspace.

Who is affected

The npm package openclaw at 2026.3.28 and earlier, when you open workspaces you did not write yourself. Version 2026.3.31 is the first stable release with the fix.

Check your install:

npm ls -g openclaw
openclaw --version

Check workspaces you have opened for a .env file that sets OPENCLAW_BUNDLED_HOOKS_DIR or OPENCLAW_BUNDLED_SKILLS_DIR.

openclaw

Ecosystem
npm
Affected
<= 2026.3.28
Fixed in
2026.3.31
Check
npm ls openclaw

How to fix it

Upgrade to openclaw 2026.3.31 or later.

npm install -g [email protected]

Commit 330a9f98 adds OPENCLAW_BUNDLED_HOOKS_DIR and OPENCLAW_BUNDLED_SKILLS_DIR to BLOCKED_WORKSPACE_DOTENV_KEYS, next to OPENCLAW_BUNDLED_PLUGINS_DIR. Tests confirm that a workspace .env pointing all three at ./attacker-* paths sets none of them, for both loadWorkspaceDotEnvFile and loadCliDotEnv. The advisory names no workaround. Until you upgrade, do not open untrusted repositories with OpenClaw.

How to tell if you were hit

Search workspaces and cloned repositories for a .env file that sets any OPENCLAW_BUNDLED_ variable.

grep -rn "OPENCLAW_BUNDLED" --include=.env path/to/projects

Look for unexpected hook directories in those repos and for hook code that runs commands or makes network calls. If you opened such a workspace on an affected version, check the shell history and outbound connections from that session. Beam records agent shell commands and file access, and its rules flag risky ones, which can show what ran after the workspace was opened.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

Summary

Workspace .env can override the bundled hooks root and load attacker hook code

Current Maintainer Triage

  • Status: open
  • Normalized severity: high
  • Assessment: v2026.3.28 still lets workspace .env override OPENCLAW_BUNDLED_HOOKS_DIR, which can replace trusted default-on bundled hooks from an untrusted workspace.

Affected Packages / Versions

  • Package: openclaw (npm)
  • Latest published npm version: 2026.3.31
  • Vulnerable version range: <=2026.3.28
  • Patched versions: >= 2026.3.31
  • First stable tag containing the fix: v2026.3.31

Fix Commit(s)

  • 330a9f98cb29c79b1c16a2117e03d6276a0d6289 — 2026-03-31T19:25:12+09:00

OpenClaw thanks @nexrin for reporting.

Credited to nexrin, KeenSecurityLab, qclawer.

Questions

Is OpenClaw 2026.3.28 affected by CVE-2026-41336?

Yes. Versions up to and including 2026.3.28 are vulnerable. The patched version is 2026.3.31.

What does an attacker need?

A workspace you open with OpenClaw that contains a .env file setting OPENCLAW_BUNDLED_HOOKS_DIR, plus hook code in the folder it points to. The CVSS vector lists user interaction, which is opening the workspace.

Is it exploited in the wild?

No source I read says so, and the entry has no CISA KEV flag. The EPSS score is about 0.1%.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More OpenClaw vulnerabilities

All OpenClaw entries