Back to skill

Security audit

OpenClaw Dream

Security checks for vulnerabilities and agentic risk

Overview

The skill is purpose-aligned memory cleanup, but it can automatically change long-term agent memory with broad triggers, inconsistent write-scope promises, and weak concurrency safeguards.

Review before installing. Use this only if you want an agent to edit persistent OpenClaw memory and memory index state. Prefer disabling cron/heartbeat until you have backups, a dry-run or diff review process, narrower explicit triggers, and a real lock around the full consolidation run.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • 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
Findings (1)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/dream-check.sh:49
Finding

Ineffective Locking Permits Concurrent Persistent-Memory Modification

Content
View full analysis

Vulnerability Details

File Location: scripts/dream-check.sh:49-60
Vulnerability Type: Race condition caused by incomplete lock implementation
Risk Level: Medium

Vulnerable Code

bash
# Check 4: Lock file (prevent concurrent dreams)
LOCK_FILE="$WORKSPACE/memory/.dream_lock"
if [ -f "$LOCK_FILE" ]; then
  LOCK_AGE=$(( ($(date +%s) - $(stat -c %Y "$LOCK_FILE")) / 60 ))
  if [ "$LOCK_AGE" -lt 30 ]; then
    echo "SKIP: dream already running (lock age: ${LOCK_AGE}m)"
    exit 1
  else
    echo "WARN: stale lock file (${LOCK_AGE}m old) — removing"
    rm -f "$LOCK_FILE"
  fi
fi

# All checks passed
echo "READY: dream should run"

The subsequent workflow is instructed to modify persistent memory in SKILL.md:91-109:

markdown
1. **Update MEMORY.md**:
   - Apply all changes from Phase 3
   - Keep total line count under 250 lines (warn if approaching)
   - Update the `*最后更新*` date at the bottom
   - Preserve existing section structure (don't reorganize unless necessary)

2. **Rebuild vector index**:
   ```bash
   openclaw memory index --force
  1. Generate dream log at memory/dream-log-YYYY-MM-DD.md:
text

### Technical Analysis

The pre-flight script checks whether `.dream_lock` already exists and may remove a stale lock, but it never creates or atomically acquires the lock. It also does not hold a lock for the duration of the read-modify-write operation.

The check and subsequent consolidation are separate operations. Multiple scheduled, heartbeat, or manually triggered agents can therefore execute the script concurrently, all observe that no lock exists, and all receive the `READY` result. Each agent may then read the same initial memory state and independently modify `MEMORY.md`, generate a log, rebuild the index, and update timestamps.

This is a time-of-check-to-time-of-use race condition. A plain existence check would remain insufficient even if a later non-atomic file creation were added. The lock must be acquired atom
...[truncated 1503 chars]
Remediation
View remediation

Remediation Suggestions

  1. Acquire an atomic lock before any scan or modification and hold it through all memory writes, index rebuilding, log generation, and timestamp updates.
  2. Prefer flock on a dedicated file descriptor, for example:
bash
LOCK_FILE="$WORKSPACE/memory/.dream_lock"
exec 9>"$LOCK_FILE"
if ! flock -n 9; then
  echo "SKIP: dream already running"
  exit 1
fi
  1. Ensure the process that performs consolidation inherits and retains the locked file descriptor. A pre-flight script that exits before consolidation cannot protect the later operation.
  2. If flock is unavailable, atomically create a lock directory with mkdir, record the owner PID and start time, and install a cleanup trap. Stale-lock removal must verify that the recorded owner is no longer active.
  3. Write the new MEMORY.md to a temporary file on the same filesystem, validate it, and use an atomic rename to replace the original.
  4. Avoid multiple processes writing the same date-based dream-log file. Use an atomic append operation or unique run identifiers.
  5. Rebuild the vector index only after the final memory file has been committed while the lock remains held.
  6. Add an integration test that launches multiple simultaneous consolidation attempts and verifies that exactly one obtains the lock and modifies persistent state.
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (17)

Intent-Code Divergence

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The skill contains an internal safety guarantee that daily note files are never modified, but earlier consolidation instructions explicitly say old entries in daily notes may be altered with supersession markers and date absolutization. This contradiction is dangerous because operators may trust the safety rule while the procedure actually permits mutation of historical records, causing integrity loss and unexpected changes to memory data.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

High
Category
Not specified by scanner
Confidence
95% confidence
Finding

The document initially claims the system only modifies memory files, but later sections describe touching non-memory artifacts such as TOOLS.md, playbooks, timestamps, logs, and index state. This contradiction is dangerous because it undermines informed consent and can hide broader write capabilities than users expect.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The README presents a narrower write scope than the documented workflow actually implies: it says the skill writes updates to MEMORY.md, while also stating it rebuilds a vector index and generates a changelog. This kind of inaccurate safety boundary can mislead operators into granting broader trust or automation privileges than intended, especially for a skill designed to run unattended via cron.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

Broad trigger phrases like 'dream' or 'clean up memory' are ambiguous and can cause accidental invocation during ordinary conversation. Because this skill performs write operations on long-lived memory artifacts and is intended for automatic use, unintended activation could lead to unauthorized or premature consolidation, data loss, or propagation of incorrect edits.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The Safety section claims the skill only modifies MEMORY.md, but earlier sections describe additional write-side effects such as rebuilding an index and producing logs/changelogs. Contradictory safety claims are dangerous because users may rely on the most restrictive statement when enabling scheduled or isolated execution, resulting in underestimation of file-system impact.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The trigger set is broad, includes common natural-language phrases, and supports automatic execution via cron/heartbeat. This raises the chance of accidental invocation, causing unintended writes to MEMORY.md, dream logs, and timestamps without a deliberate user decision.

Content

No source excerpt is available for this finding.

Skill Enumeration

Medium
Category
Agent Snooping
Confidence
80% confidence
Finding

Skill enumerates or reads other installed skills. Access to other skills' SKILL.md files or the skills directory reveals prompt instructions, capabilities, and secrets that should be invisible to peer skills.

Content

Scanner excerpt · README.md (reported line 35)May include surrounding context.

text
sessions_spawn:
  task: "Run openclaw-dream consolidation. Read the skill at skills/openclaw-dream/SKILL.md first."
  mode: run
  model: sonnet  # use a cheaper model

Skill Enumeration

Medium
Category
Agent Snooping
Confidence
80% confidence
Finding

Skill enumerates or reads other installed skills. Access to other skills' SKILL.md files or the skills directory reveals prompt instructions, capabilities, and secrets that should be invisible to peer skills.

Content

Scanner excerpt · SKILL.md (reported line 27)May include surrounding context.

text
sessions_spawn:
  task: "Run openclaw-dream consolidation. Read the skill at skills/openclaw-dream/SKILL.md first."
  mode: run
  model: sonnet  # use a cheaper model

Skill Enumeration

Medium
Category
Agent Snooping
Confidence
80% confidence
Finding

Skill enumerates or reads other installed skills. Access to other skills' SKILL.md files or the skills directory reveals prompt instructions, capabilities, and secrets that should be invisible to peer skills.

Content

Scanner excerpt · SKILL.md (reported line 175)May include surrounding context.

text
sessions_spawn:
  task: "Run openclaw-dream consolidation. Read the skill at skills/openclaw-dream/SKILL.md first."
  mode: run
  model: sonnet  # use a cheaper model

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill performs automatic modifications to memory artifacts and creates logs/timestamps, but the user-facing description does not prominently warn that execution changes files. Lack of clear disclosure undermines informed consent and makes accidental or surprising state changes more likely, especially when combined with broad triggers and scheduled execution.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill instructs execution of shell commands as part of its workflow (openclaw memory index --force and later timestamp update commands), which introduces side effects beyond passive document analysis. Even if these commands are operationally related to memory maintenance, they create an execution path that can be triggered automatically and may run in unintended contexts, expanding the blast radius if the workspace or CLI behavior is compromised.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The design expands data access beyond the stated scope of consolidating MEMORY.md and memory/*.md by also reading self-improving JSONL and potentially other artifacts. Scope expansion is risky because users may consent to memory cleanup but not to broader ingestion, inference, or modification decisions based on additional data sources.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The design enables automatic file-modifying behavior via cron and manual triggers without a clear user-facing warning that files will be changed. Background modification of persistent data is especially risky here because the skill is framed as tidy-up automation, which may mask destructive or irreversible effects.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

Broad trigger phrases like 'dream' or generic cleanup language can activate destructive maintenance behavior during ordinary conversation. In a skill that edits or deletes files, accidental invocation is a real safety issue because normal dialog may be misinterpreted as authorization to modify state.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

Automatic deletion of conflicting, duplicate, or outdated memory entries without a strong user warning or confirmation can cause silent data loss and incorrect consolidation. In this context, memory files may contain durable operational knowledge, so mistaken deletion can degrade agent behavior and erase important history.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

Rebuilding a vector index materially changes system state outside simple memory-file consolidation and is not clearly covered by the described purpose. This introduces hidden side effects, including possible corruption of search state, unintended reindexing of sensitive content, or operational changes users did not authorize.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Low
Category
Not specified by scanner
Confidence
81% confidence
Finding

The design specifies launching a separate sub-agent via sessions_spawn. While background execution may be convenient, spawning agent processes is a distinct capability not inherent to cleaning memory files and is not declared in the manifest's purpose statement.

Content

No source excerpt is available for this finding.