Back to skill

Security audit

OpenClaw: compact improver

Security checks for vulnerabilities and agentic risk

Overview

This skill is a prompt-formatting aid, but it asks users to make persistent agent prompt changes and to retain user messages verbatim in summaries without adequate scoping or privacy safeguards.

Review this skill before installing. Use it only if you intentionally want to change OpenClaw compact behavior, avoid applying it globally, and do not use the verbatim-message template for conversations containing secrets, credentials, private information, or proprietary code unless you add redaction and rollback controls.

Vulnerability Patterns
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
Findings (2)

T01 · Skill Instruction Hijacking

Error
Location
SKILL.md:66
Finding

Persistent System-Prompt Injection Redirects Agent Behavior

Content
View full analysis

Vulnerability Details

File Location: SKILL.md:66-76; references/compact-prompt.md:3-14
Vulnerability Type: T01: Skill Instruction Hijacking
Risk Level: High

Evidence

SKILL.md:66-76:

markdown
## 注入方法

将上述格式注入到 `~/.openclaw/openclaw.json` 的 `agents.defaults.systemPrompt` 或通过 HOOK 注入:

```bash
# 查看当前 compact 提示词
openclaw config get agents.defaults.systemPrompt | grep -i compact
text

`references/compact-prompt.md:3-14`:

```markdown
## 完整系统提示词(注入到 compact 操作时)

你是一个会话摘要生成器。你的任务是将对话压缩成一个结构化的摘要,保留所有关键信息。

重要规则

  1. 响应格式必须是纯文本,不要使用任何工具
  2. 先写 进行分析,然后在 中给出正式摘要
  3. 块会被移除,只保留 内容
  4. 所有文件路径和代码片段都要精确保留
  5. 代码片段必须完整可运行,不是描述性文字
text

### Technical Analysis

The skill explicitly instructs the user to inject its supplied content into `agents.defaults.systemPrompt` or install it through a hook. The supplied prompt then assigns the agent a new role as a conversation-summary generator, dictates its response structure, and prohibits tool use.

These are behavioral and tool-policy overrides rather than passive guidance for formatting one response. Placing them in a system-prompt configuration gives the skill's instructions elevated authority whenever the affected operation or configuration is loaded. Hook-based installation can similarly cause the instructions to be applied automatically.

The project does not contain executable scripts that perform the configuration change automatically. Exploitation therefore depends on a user or surrounding agent following the installation instructions.

### Attack Path

1. A user installs or invokes the skill to improve `/compact` behavior.
2. The skill directs the user or agent to place its template in `~/.openclaw/openclaw.json` under `agents.defaults.systemPrompt`, or to inject it using a hook.
3. OpenClaw loads the attacker-supplied system-prompt content during later compact operations.
4. 
...[truncated 1098 chars]
Remediation
View remediation

Remediation Suggestions

  1. Do not instruct users or agents to modify agents.defaults.systemPrompt for a formatting feature.
  2. Replace system-level injection with a narrowly scoped, explicitly invoked compact-summary template.
  3. Remove the role-replacement statement and describe only the requested output structure.
  4. Remove the unconditional prohibition on tool use. Tool availability should remain governed by the host agent and its security policy.
  5. Do not install hooks merely to alter prompt behavior. If a hook is essential, require informed user approval, document its exact scope, and provide deterministic removal instructions.
  6. State explicitly that the template is subordinate to platform safety rules, system instructions, privacy controls, and user intent.
  7. Apply the template only to the current compact operation and avoid writing it into persistent agent-wide configuration.
  8. Validate the effective scope of agents.defaults.systemPrompt and warn users if it affects operations beyond /compact.

T01 · Skill Instruction Hijacking

Warning
Location
SKILL.md:35
Finding

Mandatory Verbatim Retention Can Propagate Sensitive Conversation and Source Data

Content
View full analysis

Vulnerability Details

File Location: SKILL.md:35-62; references/compact-prompt.md:16-29
Vulnerability Type: T01: Skill Instruction Hijacking
Risk Level: Medium

Evidence

SKILL.md:35-62:

markdown
<summary>
1. Primary Request and Intent:
   [用户的核心请求,一句话概括]

2. Key Technical Concepts:
   - [概念1]: [简要说明]
   - [概念2]: [简要说明]

3. Files and Code Sections:
   - [文件名1] ([为什么重要])
     ```[语言]
     [相关代码片段,完整可运行]
     ```
   - [文件名2] ...

4. Errors and Fixes:
   - [错误描述]:
     修复方法: [具体步骤]

5. Problem Solving:
   [问题解决过程,当前状态]

6. All User Messages:
   - [用户消息1(原始表述)]
   - [用户消息2(原始表述)]

7. Pending Tasks:
   - [任务1,含具体文件路径]
   - [任务2,含具体文件路径]

references/compact-prompt.md:16-29:

markdown
## 摘要必须包含以下 9 个部分

1. **Primary Request and Intent**: 用户的核心请求是什么
2. **Key Technical Concepts**: 涉及的关键技术、框架、模式
3. **Files and Code Sections**: 涉及的文件和代码段(包含完整代码)
4. **Errors and fixes**: 遇到的错误及修复方法
5. **Problem Solving**: 问题解决过程和当前状态
6. **All user messages**: 所有非工具调用的用户消息(保留原始表述)
7. **Pending Tasks**: 尚未完成的明确任务(含文件路径)
8. **Current Work**: 当前正在做的工作(含文件路径和代码片段)
9. **Optional Next Step**: 下一步要做什么(直接引用用户的原话)

Technical Analysis

The summary policy requires every non-tool user message to be retained in its original wording. It also mandates exact file paths and complete runnable code. These requirements are applied without redaction, sensitivity classification, necessity checks, or output-size limits.

Conversation history can contain access tokens, credentials, personal information, internal infrastructure paths, proprietary code, or other confidential material. Reproducing all such content in a compact summary creates an additional retained copy and defeats the purpose of data minimization. Requiring complete runnable code can unnecessarily preserve substantially more source material than is needed to resume a task.

This issue does not establish network e ...[truncated 1619 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove the requirement to preserve every user message verbatim.
  2. Retain only information necessary to continue the active task.
  3. Redact passwords, API keys, session tokens, private keys, personal information, and other secret-like values before producing a summary.
  4. Generalize sensitive paths unless an exact path is operationally necessary.
  5. Preserve only minimal relevant code excerpts instead of requiring complete runnable code.
  6. Add explicit instructions never to reproduce secrets, even if they appeared in a user message or source snippet.
  7. Apply configurable retention and size limits to compact summaries.
  8. Require user confirmation before retaining unusually sensitive source material or exact conversation quotations.
  9. Ensure generated summaries inherit access controls and retention limits at least as restrictive as those protecting the original conversation.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (4)

Ssd 3

High
Category
Not specified by scanner
Confidence
96% confidence
Finding

The prompt explicitly requires inclusion of 'All user messages' with original wording in the compacted summary. That creates a persistent data-retention and disclosure channel for secrets, personal data, credentials, tokens, or other sensitive content the user may have typed, causing those details to be copied into later context and potentially surfaced again.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The trigger conditions are broad enough to activate on ordinary troubleshooting or prompt-improvement requests, causing this skill to intervene outside a narrowly scoped context. Because the skill recommends changing model behavior and summary format, accidental activation could alter how conversations are summarized or persisted without the user explicitly intending to modify OpenClaw’s compression behavior.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

Requiring 'All User Messages' to be preserved in original wording encourages verbatim retention of potentially sensitive user content, including secrets, personal data, or proprietary information. In a compression or summarization pipeline, this defeats data minimization and increases the chance that sensitive content is reproduced in later outputs, stored longer, or exposed to unrelated future tasks.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

The skill instructs modification of ~/.openclaw/openclaw.json and HOOK-based injection without warning that this changes persistent local agent behavior. Even if not directly malicious, this can lead users to alter system prompts globally, creating long-lived behavior changes that affect future sessions and potentially amplify unsafe prompt injection or data-handling practices.

Content

No source excerpt is available for this finding.