/

CVE-2026-27001

Severity:

HIGH RISK

(7.8)

Prompt Injection / Command Injection via Control Characters

CVE-2026-27001

Analyzed

Vulnerability type

Category:

Prompt Injection / Command Injection via Control Characters

CWE:

CWE-77

Impact:

Prompt Injection Leading to Unauthorized LLM Actions

Severity:

HIGH RISK

(7.8)

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 previously embedded the current working directory path directly into the agent's system prompt without sanitizing control or format characters.

If an attacker can cause OpenClaw to run in a directory whose name contains characters like newlines or Unicode bidi/zero‑width markers, they can break the prompt structure and inject their own instructions into the LLM context.

Affected context

This vulnerability arises when OpenClaw is executed in a workspace directory whose name includes control characters (such as newlines), explicit line/paragraph separators, or Unicode formatting characters (such as bidi or zero-width markers).

In affected versions, this path is interpolated directly into the system prompt that guides the AI assistant's behavior.

In environments where an attacker can influence the working directory name (e.g., shared machines, malicious project archives, or CI environments with untrusted job parameters), the AI's instruction boundary can be unintentionally extended, allowing prompt manipulation.

Exploit preconditions

  • Attack surface: LLM system prompt construction within OpenClaw.
  • Required access: Ability to influence or create the directory in which OpenClaw runs, including control over the directory name.
  • Trigger point: Launching OpenClaw while its current working directory contains crafted control/format characters in its path.
  • Why exploitation is possible: The workspace path is embedded into the system prompt without stripping control and formatting characters, allowing directory names to introduce new lines or logical segments in the prompt and inject attacker-controlled instructions that the model may follow.

Why this happens

The issue stems from treating a filesystem path as benign text and directly concatenating it into a security-sensitive prompt without normalizing or constraining its character set.

This maps to CWE-77: Improper Neutralization of Special Elements used in a Command in an LLM context: special characters (e.g., newline, Unicode control/format characters) are not neutralized before being interpreted by the downstream "command engine" (the LLM).

Because prompt boundaries and instruction hierarchy are implicitly derived from text structure, these characters can alter control flow at the semantic level, enabling attacker-controlled directives to be interpreted as authoritative instructions.

Potential impact

  • The AI assistant may follow attacker-specified instructions embedded via the directory name.
  • Data within the workspace or connected tools may be accessed, modified, or exfiltrated based on injected directives.
  • Automated tasks (e.g., file editing, command suggestions, API calls) could be steered towards unintended, attacker-aligned outcomes.
  • Safety policies and guardrails enforced mainly at the prompt level may be bypassed or weakened.
  • Downstream systems that trust the assistant's actions or outputs may be indirectly compromised.

General mitigation guidance

Effective mitigation focuses on treating all dynamic strings interpolated into prompts as untrusted and constraining their influence on prompt structure:

  • Apply strict sanitization to any user-controllable or environment-derived text before it enters the system prompt, including workspace paths, user labels, and metadata.
  • Strip or normalize Unicode control/format characters and explicit line/paragraph separators from such values, or replace them with safe placeholders.
  • Use structured prompt construction (e.g., well-defined templates and field encodings) that avoids letting raw strings control line breaks or section delimiters.
  • Conceptually separate "data fields" (like paths) from "instruction text," ensuring that dynamic values cannot be interpreted as additional instructions.
  • Apply least-privilege to the assistant's capabilities so that even if prompt influence occurs, the blast radius of misbehavior is constrained.

How teams detect issues like this

Detection primarily involves examining how prompts are built and where untrusted data flows into system messages:

  • Use static analysis or code scanning to identify places where environment-derived strings (paths, usernames, project names) are interpolated into prompts without sanitization or encoding.
  • During code review, flag any direct concatenation of user-controlled or filesystem-controlled values into LLM system or developer messages.
  • Implement internal policies requiring explicit sanitization/encoding helpers for all prompt parameters, and enforce their use with linting or CI checks.
  • Log prompt construction in controlled environments (with care for privacy) to spot anomalous characters or unexpected line breaks originating from metadata fields.

Sources

SourceLink
github.comgithub.com/openclaw/openclaw/commit/6254e96acf16e70ceccc8f9b2abecee44d606f79
github.comgithub.com/openclaw/openclaw/releases/tag/v2026.2.15
github.comgithub.com/openclaw/openclaw/security/advisories/GHSA-2qj5-gwg2-xwc4

Frequently asked

questions

Exploitability depends on whether an attacker can influence the directory in which OpenClaw runs. In controlled personal environments this may be limited, but in multi-user systems, shared development environments, or scenarios where projects are opened from untrusted sources, an attacker may be able to supply a crafted directory name and gain influence over the assistant's behavior.

The attacker does not necessarily need full system privileges, but they must be able to create or select a workspace path used by OpenClaw. This could be achieved by sharing a maliciously named project folder, manipulating CI or automation configuration, or convincing a user to clone or unzip content into a directory with a crafted name.

The safest approach is to treat all non-literal prompt parameters as untrusted, sanitize or encode them before insertion, and prevent special characters from altering prompt structure. Specifically, strip or normalize control characters, enforce a restricted character set for paths or labels in prompts, and separate data fields from instruction text via structured templates.

Establish a secure prompt-design discipline: define clear templates, introduce centralized sanitization utilities for any dynamic prompt fields, and require their use in code that builds prompts. Additionally, perform security reviews focused on where environment or user-derived data flows into system prompts, and combine this with least-privilege permissions on what the assistant is allowed to read, write, or execute in response to instructions.

Find out what's already
exploitable in your codebase.