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

CVE-2026-22176: OpenClaw has a Command Injection via unescaped environment assignments in Windows Scheduled Task script generation

highCVSS 4.0 7.1GHSA-pj5x-38rw-6fph

On Windows, OpenClaw 2026.2.17 and earlier wrote config-provided environment values into the gateway's Scheduled Task script as unquoted `set KEY=VALUE` lines. Shell metacharacters in a value run as commands when the task runs. Upgrade `openclaw` to 2026.2.19.

Published Mar 3, 2026 · Updated Mar 20, 2026 · Analysis Oct 31, 2026

What an attacker can do

gateway install on Windows writes a helper batch file, gateway.cmd, and registers it with schtasks. In src/daemon/schtasks.ts, environment values were rendered as set KEY=VALUE with no quoting. In cmd.exe, characters such as &, |, ^, % and ! change command behaviour, so a value like x & calc ends the assignment and starts a new command (CWE-78).

The attacker needs to influence an environment value before the task script is generated: a shared team config template, a copied config snippet, a setup script, or a repository that writes config. The CVSS 4.0 vector is local, with passive attack requirements and active user interaction, because someone has to install or reinstall the gateway.

The injected commands run with the rights of the account that runs the scheduled task and run again each time it starts. The maintainers say that on a single-user, localhost-only machine you control, practical risk is typically low. It becomes a real config-to-code-execution path when config comes from less trusted sources.

Who is affected

The openclaw npm package up to and including 2026.2.17, on Windows only, where the gateway is installed as a Scheduled Task. Check with:

npm ls -g openclaw

Also inspect the generated gateway.cmd for set lines that contain &, |, ^ or % characters in values you did not set yourself.

openclaw

Ecosystem
npm
Affected
<= 2026.2.17
Fixed in
2026.2.19
Check
npm ls openclaw

How to fix it

Upgrade to openclaw 2026.2.19 or later, then reinstall the gateway service so the script is regenerated:

npm install -g [email protected]
openclaw gateway install

The fix commit is dafe52e8cf1a041d898cfb304a485fa05e5f58fb. It renders quoted assignments, set "KEY=VALUE", escapes the cmd metacharacters, and updates the parser to read quoted assignments. The old script stays vulnerable until it is rewritten. Review any config you took from others before reinstalling.

How to tell if you were hit

Open the existing gateway.cmd and the Scheduled Task definition, and look for unquoted set lines whose values contain &, |, ^, % or !, or for extra commands after a set line. Check Windows process creation logs for unexpected child processes of cmd.exe started by the OpenClaw task. No exploitation in the wild is reported in the advisory.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

Summary

A command injection vulnerability existed in Windows Scheduled Task script generation for OpenClaw. Environment values were written into gateway.cmd using unquoted set KEY=VALUE, which allowed Windows shell metacharacters in config-provided environment variables to break out of assignment context.

Affected Packages / Versions

  • Package: openclaw (npm)
  • Affected versions: <= 2026.2.17
  • Patched version: >= 2026.2.19
  • Latest published vulnerable version at review time (2026-02-19): 2026.2.17

Practical Risk Context

For a single-user, localhost-only setup on a personally controlled machine, practical risk is typically low.

This issue becomes materially relevant when configuration or environment values are sourced from less-trusted inputs, for example:

  • shared/team config templates,
  • copied config snippets,
  • setup scripts, automation, or repos that write config,
  • any workflow where another party can influence env values before gateway install/reinstall.

In those scenarios, it provides a reliable config-to-command-execution path when the scheduled task script is generated and run.

Details

On Windows, gateway service installation writes a helper batch script and then registers it via Scheduled Task (schtasks). Before the fix, env lines were rendered as set KEY=VALUE in src/daemon/schtasks.ts, so values containing metacharacters (for example &, |, ^, %, !) could alter command behavior in cmd.exe.

The fix now renders quoted assignments (set "KEY=VALUE") with explicit escaping for cmd metacharacters, updates parser compatibility for quoted assignments, and adds regression tests for metacharacter handling and round-trip parsing.

Fix Commit(s)

  • dafe52e8cf1a041d898cfb304a485fa05e5f58fb

OpenClaw thanks @tdjackey for reporting.

Credited to tdjackey.

Questions

Is CVE-2026-22176 remotely exploitable?

Not directly. The CVSS vector is local and needs user interaction. An attacker must get a malicious environment value into config that is then used for gateway install.

Does it affect macOS or Linux?

The advisory describes only the Windows Scheduled Task script generator, src/daemon/schtasks.ts.

Do I need to reinstall the gateway after upgrading?

Yes, to regenerate gateway.cmd with the quoted, escaped assignments. This is my reading of the fix, which changes script generation at install time.

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