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

CVE-2026-41387: OpenClaw's incomplete host env sanitization blocklist allows supply-chain redirection via package-manager env overrides

highCVSS 4.0 8.5 · 3.1 9.6GHSA-j7p2-qcwm-94v4

OpenClaw before 2026.3.22 filtered per-request environment overrides for host exec with an incomplete blocklist. Package-manager and runtime variables that steer dependency fetches or startup could slip through, so an approved exec request could pull in trojanized content. Upgrade to 2026.3.22 or later.

Published Mar 31, 2026 · Updated May 6, 2026 · Analysis Oct 31, 2026

What an attacker can do

When an agent runs a command on the host, the request can carry environment overrides. OpenClaw checks them against src/infra/host-env-security-policy.json and src/infra/host-env-security.ts. That list missed variables that change where tools look for code or config. The fix adds examples such as CLASSPATH, GOFLAGS, CGO_CFLAGS, CGO_LDFLAGS, PHPRC, PHP_INI_SCAN_DIR, DENO_DIR, BUN_CONFIG_REGISTRY, LUA_PATH, GEM_HOME, GEM_PATH, BUNDLE_GEMFILE, COMPOSER_HOME and XDG_CONFIG_HOME.

The attacker needs to get an exec request approved, with the override attached. That can come from a prompt-injected agent or a crafted instruction that a user approves without seeing the environment. The approved command then looks harmless, such as an install or build, but fetches packages from attacker-controlled infrastructure or loads attacker config. The outcome is arbitrary code execution on the host through a supply-chain redirect. User interaction is required, as the approval step is part of the chain.

Who is affected

npm package openclaw, versions before 2026.3.22, wherever the agent can run host commands through the gateway or the macOS node. Check the version:

npm ls openclaw

Sandboxed execution is a different path. The advisory is about host exec.

openclaw

Ecosystem
npm
Affected
< 2026.3.22
Fixed in
2026.3.22
Check
npm ls openclaw

How to fix it

Upgrade to openclaw 2026.3.22 or later:

npm install [email protected]

Commit 7abfff756d extends the blocked variable list and makes exec fail closed. The gateway throws a Security Violation error if any override is blocked or malformed. The macOS node rejects it with SYSTEM_RUN_DENIED: environment override rejected, before approval is evaluated. Override keys must be letters, digits and underscores.

How to tell if you were hit

Review approved exec requests for environment overrides, especially registry, config-home or search-path variables. Check package manager and proxy config on hosts for registry URLs you did not set, and look for unexpected package sources in install logs. Beam records agent shell commands and the approvals around them, which helps trace what an approved command ran.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

Summary

Host exec env override sanitization did not fail closed for several package-manager and related redirect variables that can steer dependency fetches or startup behavior.

Impact

An approved exec request could silently redirect package resolution or runtime bootstrap to attacker-controlled infrastructure and execute trojanized content.

Affected Component

src/infra/host-env-security-policy.json, src/infra/host-env-security.ts

Fixed Versions

  • Affected: < 2026.3.22
  • Patched: >= 2026.3.22

Fix

Fixed by commit 7abfff756d (Exec: harden host env override handling across gateway and node).

Credited to tdjackey.

Questions

Is OpenClaw 2026.3.21 affected by CVE-2026-41387?

Yes. Every version before 2026.3.22 is affected, and 2026.3.22 holds the fix.

Does the attack need an approval?

Yes. The advisory describes an approved exec request that silently redirects package resolution or runtime bootstrap. The approval view may not show the override.

What happens when a blocked variable is sent after the fix?

The gateway raises a Security Violation error and runs nothing. The macOS node answers with SYSTEM_RUN_DENIED: environment override rejected.

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