/

CVE-2026-32063

Severity:

HIGH RISK

(7.1)

Command Injection in OpenClaw systemd Generator

CVE-2026-32063

Analyzed

Vulnerability type

Category:

Command Injection

CWE:

CWE-77

Impact:

Arbitrary Command Execution as OpenClaw Gateway Service User

Severity:

HIGH RISK

(7.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

OpenClaw versions 2026.2.19-2 prior to 2026.2.21 contain a command injection flaw in the logic that generates systemd unit files from environment configuration.

Because attacker-controlled environment values are not validated for CR/LF characters, an attacker can inject additional systemd directives and ultimately execute arbitrary commands with the privileges of the OpenClaw gateway service user when the service is installed or restarted.

Affected context

The vulnerability occurs in deployments where OpenClaw generates systemd unit files dynamically from configuration sources such as config.env.vars or similar environment-variable files.

The risk is present when:

  • Environment values are influenced by less-trusted users, automation, or external inputs
  • The systemd unit file is regenerated and installed based on these values
  • Service install, reload, or restart operations are performed (for example during deployment or configuration changes)

In such setups, newline characters embedded in environment values can break the expected Environment= line structure in the generated unit and inject arbitrary systemd configuration.

Exploit preconditions

  • Attack surface: Local or semi-local configuration interface where config.env.vars or equivalent environment values can be modified (e.g., admin panel, config file, deployment pipeline, or scriptable API).
  • Required access: Ability to influence or write one or more environment variable values that OpenClaw uses when generating systemd unit files; and the ability to trigger or wait for a service install/restart/reload.
  • Trigger point: Execution of the systemd unit generation/install logic, followed by systemd starting or reloading the affected OpenClaw gateway service.
  • Why exploitation is possible: The generator writes unvalidated, attacker-controlled strings directly into Environment= directives, without sanitizing or encoding CR/LF characters. Newlines inside a value terminate the current directive and start new lines that systemd interprets as independent configuration directives, including ones that can reference or execute external commands.

Why this happens

This issue stems from improper neutralization of special elements used in command contexts, aligning with CWE-77: Improper Neutralization of Special Elements used in a Command.

The code assumes that environment variable values can be safely embedded into Environment= lines in a systemd unit file without considering that CR (\r) and LF (\n) characters have structural meaning in this configuration language.

By not stripping, rejecting, or encoding newline characters, the implementation effectively allows untrusted input to escape its intended value boundary and become executable configuration, which systemd can use to run commands or change service behavior.

Potential impact

  • Execution of arbitrary commands with the privileges of the OpenClaw gateway service user
  • Modification of service behavior, including changing ExecStart/ExecStartPre/ExecStartPost directives
  • Installation of backdoors through persistent malicious unit directives
  • Lateral movement on the host, depending on the permissions of the service user and local configuration
  • Disruption of service availability by injecting directives that cause startup failure or repeated crashes

General mitigation guidance

Effective mitigation focuses on treating environment-derived values as untrusted and preventing them from altering the structure of configuration files:

  • Normalize and validate all environment values before embedding them in unit files, rejecting or stripping CR/LF characters and other structural delimiters.
  • Use robust encoding or quoting mechanisms when interpolating values into configuration templates, ensuring that injected newlines cannot break out of the intended directive.
  • Restrict who can modify configuration inputs like config.env.vars, applying least-privilege principles to configuration management paths and deployment pipelines.
  • Prefer fixed, declarative unit files where possible and minimize dynamic unit generation, or constrain the set of allowed directives when generation is required.
  • Run the OpenClaw gateway service under a minimally privileged account and avoid unnecessary local permissions, reducing the blast radius of any successful command execution.

How teams detect issues like this

Detection typically involves both code-focused and configuration-focused approaches:

  • Static analysis and code review: Look for code paths that write user-controlled strings directly into systemd unit files or other configuration files without filtering CR/LF or performing strict validation. Pay attention to string concatenation or templating around Environment=, ExecStart=, and similar directives.
  • Template and policy checks: Implement validation rules or schema checks for generated unit files prior to installation, flagging unexpected extra directives or lines derived from configurable inputs.
  • Configuration hygiene monitoring: Periodically scan installed systemd unit files for anomalies such as unexpected directives, unusual Exec* commands, or suspicious environment values.
  • Automated security tooling: Use configuration linters, SAST tools, or CI/CD checks that can detect newline injection patterns and unsafe interpolation of untrusted data into configuration or command contexts.

Sources

SourceLink
github.comgithub.com/openclaw/openclaw/commit/61f646c41fb43cd87ed48f9125b4718a30d38e84
github.comgithub.com/openclaw/openclaw/security/advisories/GHSA-vffc-f7r7-rx2w
vulncheck.comvulncheck.com/advisories/openclaw-command-injection-via-newline-in-systemd-unit-generation

Frequently asked

questions

It can be, if configuration values (config.env.vars or similar) are influenced by remote inputs such as web UIs, APIs, or automated deployment systems accessible over the network. If only local administrators can change these values, the exploitability is limited to those users.

An attacker must be able to control or significantly influence the environment variable values used in unit generation and ensure that the service install/restart occurs. This might require access to configuration files, a management interface, or a compromised CI/CD pipeline.

The safest pattern is to strictly validate and sanitize all environment values before they are written into systemd unit files, explicitly disallowing CR/LF and other line-breaking characters, and to use robust quoting/encoding in templates so that configuration data cannot change the structure of the unit file.

Treat all configuration inputs as untrusted, especially when they are interpolated into command or configuration contexts. Apply rigorous input validation, output encoding, and clear separation between data and control structures. Incorporate security reviews and automated checks into the development and deployment pipelines for any feature that generates scripts or configuration files from user-provided data.

Find out what's already
exploitable in your codebase.