The vulnerability exists in the handling of .env files within an OpenClaw workspace. The application did not properly restrict environment variables that could be set through a workspace's .env file. Specifically, it failed to block variables prefixed with OPENCLAW_, which are used for runtime control of the OpenClaw application. This allows an attacker who controls the workspace to define malicious OPENCLAW_ variables in the .env file (e.g., OPENCLAW_GIT_DIR), thereby manipulating the application's behavior.
The patch addresses this by adding "OPENCLAW_" to the BLOCKED_WORKSPACE_DOTENV_PREFIXES list in src/infra/dotenv.ts. This ensures that any environment variable from a workspace .env file starting with this prefix is blocked.
The key vulnerable function is loadWorkspaceDotEnvFile, which is responsible for reading and applying the workspace's .env file. The function shouldBlockWorkspaceDotEnvKey contains the flawed logic that was fixed. The higher-level function loadDotEnv is the entry point that triggers this vulnerable behavior. During exploitation, these functions would appear in a runtime profile as they are involved in processing the malicious .env file.