CVE-2026-41294: OpenClaw has a CWD `.env` environment variable injection which bypasses host-env policy and allows config takeover
OpenClaw up to 2026.3.24 loaded a `.env` file from the current working directory before its trusted state-directory config. A cloned repository with a malicious `.env` could override proxies, API base URLs, TLS checks and OpenClaw's own config paths when you started OpenClaw there. Fixed in 2026.3.28.
Published Apr 1, 2026 · Updated Apr 20, 2026 · Analysis Oct 30, 2026
What an attacker can do
OpenClaw read .env from whatever directory it was started in, and did so before trusted configuration. The code is in src/infra/dotenv.ts and src/cli/dotenv.ts. A repository or workspace that ships a .env could therefore set host environment values for the OpenClaw process, and those values took precedence over the user's global .env for shared keys.
The fix commit shows which values mattered: proxy variables (HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, NO_PROXY), NODE_TLS_REJECT_UNAUTHORIZED, NODE_OPTIONS, any key ending in _BASE_URL such as ANTHROPIC_BASE_URL, and OpenClaw's location variables (OPENCLAW_STATE_DIR, OPENCLAW_CONFIG_PATH, OPENCLAW_HOME and others).
The attacker needs the user to open OpenClaw in a directory they control, such as a cloned repo, which is why the vector has user interaction. The results follow from the variables: point the model API base URL at an attacker server to capture prompts and keys, route traffic through a proxy with TLS checks disabled, load code through NODE_OPTIONS, or redirect the state directory to an attacker-chosen config. The advisory title calls the last case config takeover. For a team, the danger is running an agent inside an untrusted checkout.
Who is affected
openclaw (npm) up to and including 2026.3.24. 2026.3.28 contains the fix. You are exposed if you start OpenClaw from directories that hold files you did not write.
npm ls openclawAlso check repositories you opened with OpenClaw for a .env file that sets proxy, *_BASE_URL, OPENCLAW_* or NODE_OPTIONS values.
openclaw
- Ecosystem
- npm
- Affected
- <= 2026.3.24
- Fixed in
- 2026.3.28
- Check
npm ls openclaw
How to fix it
Upgrade to 2026.3.28 or later:
npm install [email protected]Commit 6a79324 filters untrusted entries from the working directory .env. It blocks dangerous host variables, the proxy and TLS keys above, the OPENCLAW_* location variables, PI_CODING_AGENT_DIR, and any *_BASE_URL key. Ordinary keys still load. Values already in the process environment are never overridden. The working-directory file also cannot change which global .env is read. A trusted global .env can still set ANTHROPIC_BASE_URL and proxies. The sources list no workaround besides not starting OpenClaw in untrusted directories.
How to tell if you were hit
Search the directories where you ran OpenClaw for .env files you did not create, and read them for *_BASE_URL, HTTP_PROXY, HTTPS_PROXY, NODE_TLS_REJECT_UNAUTHORIZED, NODE_OPTIONS and OPENCLAW_ entries. Check OpenClaw's active state and config path for an unexpected location. Look in network logs for model API calls going to an unfamiliar host or proxy. If a hostile .env was loaded, treat API keys used in that session as exposed.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
Summary
OpenClaw loaded the current working directory .env before trusted state-dir configuration, allowing untrusted workspace state to inject host environment values.
Impact
A repository or workspace containing a malicious .env file could override runtime configuration and security-sensitive environment settings when OpenClaw started there.
Affected Component
src/infra/dotenv.ts, src/cli/dotenv.ts
Fixed Versions
- Affected:
<= 2026.3.24 - Patched:
>= 2026.3.28 - Latest stable
2026.3.28contains the fix.
Fix
Fixed by commit 6a79324802 (Filter untrusted CWD .env entries before OpenClaw startup).
Credited to tdjackey.
Questions
- Does this need the attacker to touch my machine?
No. A malicious repository that you clone and open OpenClaw in is enough. The CVSS vector marks user interaction as required.
- Which settings did a hostile .env override?
The fix commit blocks proxy variables,
NODE_TLS_REJECT_UNAUTHORIZED,NODE_OPTIONS,*_BASE_URLkeys and theOPENCLAW_*directory and config variables, which shows what an attacker could set.- Can a project .env still set things after 2026.3.28?
Ordinary keys still load from the working directory
.env. The blocklisted ones do not.
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 entriesCVE-2026-62197
OpenClaw: Browser CDP discovery could accept blocked WebSocket URLs
medium8.5Oct 21, 2026CVE-2026-35630
OpenClaw: QQBot native approval buttons did not enforce configured approver identity
high8.0Jul 2, 2026CVE-2026-53806
OpenClaw: Combined POSIX shell options could confuse exec revalidation
high8.8Jul 2, 2026CVE-2026-53809
OpenClaw: Embedded runner policy could be confused by provider aliases
medium3.8Jul 2, 2026CVE-2026-53810
OpenClaw's marketplace runtime extension metadata could point at unscanned payloads
high8.8Jul 2, 2026CVE-2026-53811
OpenClaw: Matrix allowFrom could bind to mutable display names
high8.8Jul 2, 2026
