Back to skill

Security audit

Auto Reflection

Security checks for vulnerabilities and agentic risk

Overview

This auto-reflection skill is not malicious, but it automatically writes persistent workspace and agent-context files and the shipped script is currently broken, so it needs review before installation.

Review before installing. This skill is intended to maintain reflection state, but it automatically changes files that may influence future agent behavior. Install only if you are comfortable with it writing under D:\OpenClaw\workspace, and prefer adding an explicit confirmation or dry-run mode, input validation before writing HEARTBEAT.md, and a fix for the current JavaScript syntax error.

Vulnerability Patterns
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • 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
  • 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 (2)

T02 · Agent Memory Poisoning

Warning
Location
index.js:121
Finding

Persistent Agent Memory Poisoning Through Unsanitized Reflection Content

Content
View full analysis

Vulnerability Details

File Location: index.js, lines 121 and 235-258
Vulnerability Type: Persistent injection into an Agent context file
Risk Level: Medium

Complete Code Snippet

js
achievements: capabilities.recentAchievements || [],
js
${reflection.achievements.map(a => `- ✅ ${a}`).join('\n')}

### Improvement Suggestions
${reflection.metaCognition.suggestions.map(s => `${s}`).join('\n')}

---
`;

const marker = '## 💭 Latest Reflection';
const markerIndex = content.indexOf(marker);

if (markerIndex >= 0) {
  const nextSectionIndex = content.indexOf('##', markerIndex + 1);
  if (nextSectionIndex >= 0) {
    content = content.substring(0, markerIndex) + 反思 Section + content.substring(nextSectionIndex);
  }
} else {
  content = 反思 Section + content;
}

fs.writeFileSync(heartbeatPath, content);

Technical Analysis

The skill loads recentAchievements from the mutable capabilities.json file and embeds every value directly into HEARTBEAT.md without schema enforcement, escaping, content separation, or validation for instruction-like Markdown.

Other generated suggestions can also incorporate values from capabilities.learningPath. Consequently, data controlled through the capability state can cross a trust boundary from a data file into a persistent file that may be consumed as Agent context.

If an attacker can modify capabilities.json, a value can contain Markdown headings, forged policy text, or instructions directed at the Agent. The skill then persists that content in HEARTBEAT.md. Unlike a transient output injection, the malicious content can continue influencing later sessions whenever the heartbeat file is loaded.

The present syntax defect described in the second finding prevents this path from executing in the audited version. The memory-poisoning path becomes reachable if that typo is corrected without also adding content validation.

Attack Path

  1. Obtain write access to `D:\OpenClaw\workspace\memo ...[truncated 1245 chars]
Remediation
View remediation

Remediation Suggestions

  1. Treat every value loaded from capabilities.json and knowledge-graph.json as untrusted data.
  2. Validate input with a strict schema, including permitted types, maximum lengths, and expected character sets.
  3. Reject or neutralize Markdown headings, code fences, links, HTML, and instruction-like content before writing values into an Agent context file.
  4. Store generated reflection data in a dedicated data file that is not interpreted as Agent instructions.
  5. If heartbeat updates are necessary, place untrusted values inside an explicitly delimited data section and configure the consuming Agent to treat that section only as quoted data.
  6. Require user confirmation before modifying persistent Agent context.
  7. Use atomic writes and preserve a backup of the previous heartbeat file.
  8. Add tests using payloads containing forged headings and Agent instructions to verify that they cannot escape the intended data section.

T09 · Insecure Skill Coding Practices

Note
Location
index.js:251
Finding

Invalid Identifier Prevents Skill Execution

Content
View full analysis

Vulnerability Details

File Location: index.js, lines 251 and 255
Vulnerability Type: Source-level syntax error causing denial of service
Risk Level: Low

Complete Code Snippet

js
if (markerIndex >= 0) {
  const nextSectionIndex = content.indexOf('##', markerIndex + 1);
  if (nextSectionIndex >= 0) {
    content = content.substring(0, markerIndex) + 反思 Section + content.substring(nextSectionIndex);
  }
} else {
  content = 反思 Section + content;
}

Technical Analysis

The variable declared earlier in the function is a single identifier, but both uses shown above contain whitespace between its two components. JavaScript therefore cannot parse these expressions as a reference to the declared variable.

Because parsing occurs before execution, this defect prevents the entire module from loading. None of the exported functions or direct-run behavior can be used, including capability updates, reflection generation, logging, and heartbeat synchronization.

This is primarily an availability and insecure coding issue rather than a privilege-escalation vulnerability. It also currently blocks exploitation of the persistent content-injection path identified in the first finding.

Attack Path

  1. Run the documented command that executes index.js, or import the module from another Node.js component.
  2. The Node.js parser reaches the malformed expression at line 251.
  3. Parsing terminates with a syntax error.
  4. The skill exits before performing any documented operation.

No special privileges or attacker-controlled input are required to trigger the failure.

Impact Assessment

The defect causes complete loss of availability for this skill. It does not provide an attacker with additional privileges, data access, command execution, or network access.

The affected scope includes every workflow that directly executes or imports this module. Automated reflection, capability metadata updates, report generation, and heartbeat updates canno ...[truncated 40 chars]

Remediation
View remediation

Remediation Suggestions

  1. Replace both malformed references with the exact identifier declared for the reflection section variable.
  2. Run node --check index.js as part of local validation and continuous integration.
  3. Add a smoke test that imports the module and invokes its exported functions against an isolated temporary workspace.
  4. Configure a JavaScript linter to detect parsing errors and undeclared identifiers.
  5. After correcting the syntax defect, address the persistent content-injection finding before enabling heartbeat updates.
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 (9)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The skill declares reflective/optimization behavior but the documented behavior includes undeclared file-writing side effects such as modifying HEARTBEAT.md, updating capabilities.json, and writing reports. This mismatch is dangerous because users or orchestrators may grant trust based on the stated purpose while the skill can persist changes to workspace state, enabling unintended data modification or stealthy persistence in operational files.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
73% confidence
Finding

The skill description and trigger metadata are presented as if the skill operates in Chinese by default, with no indication that users can choose another language or locale. This can violate a language-choice policy when a skill implicitly constrains interaction language without explicit opt-in or justification.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The trigger list contains broad natural-language phrases like reflection/反思 and learning optimization/学习优化 that can easily appear in ordinary conversation. That creates a risk of accidental invocation, causing the skill to run and potentially write files or alter state when the user did not intend to activate it.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The automatic activation condition 'every 5 rounds' is ambiguous because it does not clearly define what counts as a round, who tracks it, or what safety checks apply before state changes occur. Ambiguous auto-execution increases the chance of unreviewed runs and repeated file modifications, especially in long-running agent sessions.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The manifest-level description and module header state that learning plans are automatically adjusted and the knowledge graph is automatically optimized. In the implementation, the code reads capabilities and the knowledge graph, writes a reflection report, updates HEARTBEAT.md, and only bumps capability timestamps/version; it never modifies learningPath content or performs any knowledge-graph optimization logic.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The code automatically writes a reflection report and then updates HEARTBEAT.md without any confirmation, preview, or dry-run mode. In an agent setting, silent file mutation can cause unintended persistence, overwrite important documentation, and create opportunities for integrity loss if the underlying reflection data is malformed or adversarially influenced.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The skill rewrites capabilities.json automatically on every run by updating timestamps and version metadata, despite the description not clearly warning about persistent state changes. Automatic mutation of memory/state files can interfere with auditability, trigger downstream workflows, or mask whether substantive assessments actually changed.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

The skill modifies HEARTBEAT.md in the workspace even though that side effect is not clearly disclosed in the description. Undisclosed writes to user/workspace documents can corrupt or overwrite human-maintained content and reduce trust, especially in automated agent environments.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The code hardcodes toLocaleString('zh-CN') when rendering reflection timestamps, which imposes a specific locale in output. There is no user opt-in, configurability, or documented region-specific justification for requiring Chinese locale formatting.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.