CVE-2026-32063: OpenClaw Improperly Neutralizes Line Breaks in systemd Unit Generation Enables Local Command Execution (Linux)
On Linux, OpenClaw 2026.2.19-2 and earlier writes `config.env.vars` values into its systemd unit without rejecting line breaks. A newline injects a directive such as `ExecStartPre=` that runs on the next service restart as the gateway user. Upgrade to openclaw 2026.2.21.
Published Mar 3, 2026 · Updated Mar 16, 2026 · Analysis Oct 31, 2026
What an attacker can do
renderEnvLines in src/daemon/systemd-unit.ts writes Environment= lines from config.env.vars. It did not reject CR or LF in keys or values. systemd reads unit files line by line, so a value like ok followed by a newline and ExecStartPre=/bin/touch /tmp/oc15789_rce produces a separate directive line. A second bug made it worse: the regex in systemdEscapeArg was written so that \s matched a literal backslash and s instead of whitespace, so quoting was also wrong.
The chain needs three steps: the attacker influences config.env.vars directly or indirectly, the install or reinstall path (openclaw gateway install --force) rewrites the unit, and the service restarts. The injected command then runs with the gateway service user's rights. The vector is local with no privileges listed, but control of the config is the real precondition.
This matters where config can be written by something less trusted than the service user, such as a shared config repository, a provisioning pipeline, or an agent that can edit OpenClaw settings. It affects Linux hosts using systemd user services.
Who is affected
openclaw (npm) versions up to and including 2026.2.19-2 on Linux with systemd user services. You are exposed if an attacker can set config.env.vars and the gateway unit gets reinstalled and restarted.
npm ls openclaw
grep -n -E '^(ExecStartPre|ExecStartPost)' ~/.config/systemd/user/openclaw-gateway.serviceThe second command shows injected directives in the default unit path.
openclaw
- Ecosystem
- npm
- Affected
- <= 2026.2.19-2
- Fixed in
- 2026.2.21
- Check
npm ls openclaw
How to fix it
Upgrade to openclaw 2026.2.21:
npm install [email protected]Then reinstall the unit so it is regenerated, and review it. The fix adds assertNoSystemdLineBreaks, which throws "cannot contain CR or LF characters" for environment names, values, the Description and escaped arguments. It also corrects the whitespace regex to /[\s"\\]/. The sources give no workaround. Until then, treat config.env.vars as trusted input only.
How to tell if you were hit
Inspect ~/.config/systemd/user/openclaw-gateway.service for directives you did not add, especially ExecStartPre= or ExecStartPost= lines near Environment= entries. Check config.env.vars for values containing newlines. Look for files such as /tmp/oc15789_rce, the one the public PoC creates. Beam records agent file access and shell commands, which helps if an agent edited the config.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
Summary
A command injection vulnerability exists in OpenClaw’s Linux systemd unit generation path. When rendering Environment= entries, attacker-controlled values are not rejected for CR/LF, and systemdEscapeArg() uses an incorrect whitespace-matching regex. This allows newline injection to break out of an Environment= line and inject standalone systemd directives (for example, ExecStartPre=). On service restart, the injected command is executed, resulting in local arbitrary command execution (local RCE) under the gateway service user.
---
Details
The issue is in src/daemon/systemd-unit.ts:
renderEnvLines(...)builds:Environment=${systemdEscapeArg(${key}=${value})}- No CR/LF validation is enforced for environment keys/values before writing unit lines.
systemdEscapeArg(...)uses:/[\\s"\\\\]/- In this regex,
\\sis interpreted as a literal backslash +s, not a whitespace character class.
As a result, whitespace detection/quoting behavior is incorrect. Because systemd parses unit files line-by-line, a newline inside an environment value can inject an additional directive line. Example rendered output:
Environment=INJECT=ok
ExecStartPre=/bin/touch /tmp/oc15789_rceAt restart time, systemd executes ExecStartPre, enabling command execution.
Relevant code path/components involved in exploitation chain:
src/daemon/systemd-unit.tssrc/commands/daemon-install-helpers.tssrc/config/env-vars.tssrc/config/zod-schema.ts
Trigger conditions:
- Attacker can influence
config.env.vars(directly or indirectly). - Install/reinstall path is invoked to write/update the unit.
- Service restart occurs (
systemctl --user restart ...).
---
PoC
Environment: Linux host with systemd user services enabled.
- Configure a malicious environment value in OpenClaw config (
config.env.vars), including a newline and injected directive: - Key:
INJECT - Value:
ok
ExecStartPre=/bin/touch /tmp/oc15789_rce- Install/reinstall the gateway service (fixed port as requested):
openclaw gateway install --port 15789 --force- Inspect the generated user unit file (default path):
~/.config/systemd/user/openclaw-gateway.serviceVerify that an injected standalone line exists:
ExecStartPre=/bin/touch /tmp/oc15789_rce- Reload and restart user service:
systemctl --user daemon-reloadsystemctl --user restart openclaw-gateway.service- Confirm command execution side effect:
ls -l /tmp/oc15789_rce---
Impact
This is a local command execution vulnerability in OpenClaw’s systemd unit generation during install/reinstall flows.
- Type: Command injection via newline/directive injection in unit file generation.
- Execution context: Runs with the same privileges as the OpenClaw gateway service user.
- Affected users: Linux deployments using systemd user services where an attacker can control
config.env.varsand trigger install/reinstall.
Fix Commit(s)
61f646c41fb43cd87ed48f9125b4718a30d38e84
Credited to tdjackey.
Questions
- Does CVE-2026-32063 need a restart?
Yes. The injected
ExecStartPre=line runs when systemd restarts the gateway service, after the unit has been rewritten by an install or reinstall.- Does it affect macOS or Windows?
The advisory covers the Linux systemd unit generation path. It describes no impact on other platforms.
- Which version fixes it?
openclaw 2026.2.21. Versions up to 2026.2.19-2 are affected.
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
