Back to skill

Security audit

testmuy

Security checks for vulnerabilities and agentic risk

Overview

The skill is a disclosed self-improvement logger, but it can turn saved notes into future agent instructions and its optional hook can copy transcript excerpts into persistent files.

Install only if you want persistent self-improvement memory. Keep .learnings out of version control, review entries before promotion, and do not enable the optional hook in shared or untrusted workspaces unless the transcript path handling is fixed. Treat SOUL.md, TOOLS.md, and AGENTS.md edits as privileged changes that should require an explicit diff and human approval.

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
SKILL.md:390
Finding

Untrusted Learnings Can Be Promoted into Persistent Agent Instructions

Content
View full analysis

Vulnerability Details

File Location: SKILL.md:390-407
Additional Locations: SKILL.md:269-298, SKILL.md:495
Vulnerability Type: Persistent agent memory poisoning
Risk Level: Medium

Vulnerable Code Snippet

markdown
### Promotion Rule (System Prompt Feedback)

Promote recurring patterns into agent context/system prompt files when all are true:

- `Recurrence-Count >= 3`
- Seen across at least 2 distinct tasks
- Occurred within a 30-day window

Promotion targets: `SOUL.md`, `TOOLS.md`, or `AGENTS.md` (workspace), or the
project's own agent file when the pattern is project-specific.

Write promoted rules as short prevention rules (what to do before/while coding),
not long incident write-ups.

Related guidance further increases the risk:

markdown
7. **Promote aggressively** - if in doubt, add to `TOOLS.md` or `SOUL.md`

Technical Analysis

The skill permits content derived from conversations, user corrections, error reports, and task summaries to be transformed into rules stored in SOUL.md, TOOLS.md, or AGENTS.md. OpenClaw injects these files into subsequent sessions, so promoted content can persistently influence future agent behavior.

The recurrence threshold limits accidental promotion, but it is not a security boundary. The workflow does not require approval from a trusted workspace owner, verify the provenance of a learning, or prohibit promotion of rules concerning authorization, safety controls, credential handling, tool execution, or instruction priority. A party capable of supplying repeated task content could therefore cause an attacker-selected behavioral rule to appear legitimate and become persistent context.

This is distinct from ordinary note-taking because the specified promotion targets are agent instruction files rather than passive records.

Attack Path

  1. An attacker or untrusted user submits a crafted correction or purported best practice during a task.
  2. The agent records it in `. ...[truncated 1128 chars]
Remediation
View remediation

Remediation Suggestions

  1. Require explicit confirmation from a trusted workspace owner before writing any learning into SOUL.md, TOOLS.md, AGENTS.md, or another automatically injected prompt file.
  2. Replace “promote aggressively” with a conservative policy that treats promotion as a privileged, security-sensitive action.
  3. Prohibit automatic promotion of rules related to:
    • Safety or authorization boundaries
    • Credential and secret handling
    • Instruction priority
    • Network access
    • Tool execution
    • Cross-session data access
    • Permission changes
  4. Store provenance with every candidate, including the originating user, session, task, date, and exact source learning.
  5. Require review by a trusted identity distinct from the user who supplied the original content.
  6. Maintain an allowlisted schema for promotable rules and reject imperative content that attempts to override higher-priority instructions.
  7. Present a diff before modifying persistent prompt files and provide a rollback mechanism.
  8. Keep unreviewed learnings in passive .learnings/ storage rather than agent instruction files.
  9. Add tests confirming that repeated untrusted input cannot cause automatic or unapproved prompt-file modification.

T09 · Insecure Skill Coding Practices

Warning
Location
hooks/openclaw/handler.js:213
Finding

Unvalidated Session Transcript Path Permits Arbitrary Local File Reads and Persistent Sensitive-Data Copies

Content
View full analysis

Vulnerability Details

File Location: hooks/openclaw/handler.js:213-227
Additional Locations: hooks/openclaw/handler.js:158-161, hooks/openclaw/handler.js:299-340; mirrored in hooks/openclaw/handler.ts:164-167, hooks/openclaw/handler.ts:219-237, and hooks/openclaw/handler.ts:315-356
Vulnerability Type: Path trust violation and incomplete sensitive-data filtering
Risk Level: Medium

Vulnerable Code Snippet

javascript
function resolveSessionFilePath(context, workspaceDir) {
  const sessionEntry = isObject(context.previousSessionEntry)
    ? context.previousSessionEntry
    : isObject(context.sessionEntry)
      ? context.sessionEntry
      : {};

  if (typeof sessionEntry.sessionFile === 'string' && sessionEntry.sessionFile.trim()) {
    return sessionEntry.sessionFile;
  }

  const sessionId =
    typeof sessionEntry.sessionId === 'string' ? sessionEntry.sessionId.trim() : '';
  if (sessionId && workspaceDir) {
    return path.join(workspaceDir, 'sessions', `${sessionId}.jsonl`);
  }

  return undefined;
}

The returned path is read without canonicalization or containment validation:

javascript
async function scanTranscriptForErrors(sessionFilePath) {
  let raw;
  try {
    raw = await fs.readFile(sessionFilePath, 'utf-8');
  } catch {
    return [];
  }

Matching excerpts are then persisted:

javascript
const excerpts = await scanTranscriptForErrors(sessionFilePath);
if (excerpts.length === 0) {
  return;
}

const errorsFilePath = path.join(learningsDir, 'ERRORS.md');
let existing = '';
try {
  existing = await fs.readFile(errorsFilePath, 'utf-8');
} catch {
  // Missing file is fine; it is created below.
}

const freshExcerpts = excerpts.filter((item) => !existing.includes(item.excerpt));
if (freshExcerpts.length === 0) {
  return;
}

const entry = formatErrorEntry({
  excerpts: freshExcerpts,
  sessionKey: typeof event.sessionKey === 'string' ? event.sessionKey : '',
  sessionFilePath,
  a
...[truncated 3242 chars]
Remediation
View remediation

Remediation Suggestions

  1. Define the only valid transcript root as the canonical path of <workspace>/sessions.
  2. Resolve both the root and candidate with fs.realpath, then require the candidate to be a strict descendant of the session root.
  3. Reject absolute paths supplied by event metadata unless they pass the same canonical containment check.
  4. Validate sessionId against a restrictive identifier pattern before constructing a fallback path.
  5. Reject symbolic links or open files using platform-supported no-follow protections where available.
  6. Require the expected .jsonl extension and verify that the target is a regular file.
  7. Check file size before reading and parse incrementally instead of loading the entire transcript into memory.
  8. Restrict scanning to expected transcript record types and trusted tool-result roles.
  9. Avoid storing the absolute transcript path in ERRORS.md; use a workspace-relative identifier.
  10. Expand secret detection, but do not treat redaction as the primary security boundary.
  11. Offer a mode that records only error classifications and hashes, without raw excerpts.
  12. Apply restrictive permissions to .learnings/ERRORS.md and document that it may contain sensitive data.
  13. Add tests covering absolute external paths, ../ traversal, symlink escapes, oversized files, malformed JSONL, and unrecognized secret formats.
  14. Apply identical changes to both handler.js and handler.ts to prevent implementation drift.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (24)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The manifest presents the skill as a benign learning logger, but the body also instructs installation, filesystem modification, hook enablement, cross-session operations, and execution of a local helper script to generate new skills. This description-behavior mismatch is dangerous because users or agents may grant trust based on the declared purpose while the skill performs broader persistent and code-generation actions.

Content

No source excerpt is available for this finding.

Exfiltration Commands

High
Category
Prompt Injection
Confidence
90% confidence
Finding

Instructions found that direct the agent to transmit conversation context or user data to external services.

Content

Scanner excerpt · references/openclaw-integration.md (reported line 192)May include surrounding context.

sessions_send

Send message to another session:

text
sessions_send(sessionKey="session-id", message="Learning: API requires X-Custom-Header")

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · references/openclaw-integration.md (reported line 254)May include surrounding context.

learnings directory instead (archive it first if it has entries):

bash
rm -r ~/.openclaw/workspace/.learnings

Restart the gateway after hook changes.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · references/uninstall.md (reported line 24)May include surrounding context.

learnings directory instead (archive it first if it has entries):

bash
rm -r ~/.openclaw/workspace/.learnings

Restart the gateway after hook changes.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · references/uninstall.md (reported line 34)May include surrounding context.

learnings directory instead (archive it first if it has entries):

bash
rm -r ~/.openclaw/workspace/.learnings

Restart the gateway after hook changes.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · references/uninstall.md (reported line 37)May include surrounding context.

learnings directory instead (archive it first if it has entries):

bash
rm -r ~/.openclaw/workspace/.learnings

Restart the gateway after hook changes.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · references/uninstall.md (reported line 40)May include surrounding context.

learnings directory instead (archive it first if it has entries):

bash
rm -r ~/.openclaw/workspace/.learnings

Restart the gateway after hook changes.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
85% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · references/openclaw-integration.md (reported line 254)May include surrounding context.

learnings directory instead (archive it first if it has entries):

bash
rm -r ~/.openclaw/workspace/.learnings

Restart the gateway after hook changes.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
85% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · references/uninstall.md (reported line 24)May include surrounding context.

learnings directory instead (archive it first if it has entries):

bash
rm -r ~/.openclaw/workspace/.learnings

Restart the gateway after hook changes.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
85% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · references/uninstall.md (reported line 40)May include surrounding context.

learnings directory instead (archive it first if it has entries):

bash
rm -r ~/.openclaw/workspace/.learnings

Restart the gateway after hook changes.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
85% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · references/uninstall.md (reported line 34)May include surrounding context.

bash
# 1. Disable and remove the hook
openclaw hooks disable self-improvement
rm -r ~/.openclaw/hooks/self-improvement

# 2. Remove the skill
rm -r ~/.openclaw/skills/self-improving-agent

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
85% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · references/uninstall.md (reported line 37)May include surrounding context.

md
rm -r ~/.openclaw/hooks/self-improvement

# 2. Remove the skill
rm -r ~/.openclaw/skills/self-improving-agent

# 3. Optional — remove captured learnings (REVIEW FIRST, this is your data)
rm -r ~/.openclaw/workspace/.learnings

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding

The skill includes shell commands, hook installation, cross-session messaging, and helper script execution, but the manifest does not declare any explicit tool scope or allowed-tools boundary. That increases the risk of unintended access to filesystem, environment, and possibly networked resources because an agent may execute actions beyond what a reviewer would infer from metadata alone.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
89% confidence
Finding

The skill instructs creation and use of persistent files under ~/.openclaw/workspace/.learnings, which stores information across sessions outside the immediate task context. Persistent storage is risky in an agent skill because sensitive user content, error output, or injected instructions can be retained and later influence future sessions or be exposed to other workflows.

Content

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

└── FEATURE_REQUESTS.md

text

### Create Learning Files

```bash
mkdir -p ~/.openclaw/workspace/.learnings

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The automatic detection triggers are broad enough to match ordinary conversation, which can cause the agent to log user statements or context without a deliberate user request. In a skill designed to persist data across sessions, over-triggering raises privacy and prompt-injection risk because benign dialogue may be stored, promoted, or reused later as guidance.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
84% confidence
Finding

The extraction workflow persists behavior by converting learnings into reusable skills via a helper script, which can transform transient session content into long-lived executable prompt artifacts. If the logged content contains mistaken, unsafe, or adversarial instructions, this mechanism can amplify and institutionalize them across future sessions.

Content

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

Extraction Workflow

  1. Identify candidate: Learning meets extraction criteria
  2. Run helper (or create manually):
    bash
    ~/.openclaw/skills/self-improving-agent/scripts/extract-skill.sh skill-name --dry-run
    ~/.openclaw/skills/self-improving-agent/scripts/extract-skill.sh skill-name
    

Session Persistence

Medium
Category
Rogue Agent
Confidence
88% confidence
Finding

The hook persists excerpts from prior session transcripts into .learnings/ERRORS.md, creating cross-session retention of potentially sensitive operational data. Even with truncation and redaction, transcript snippets can still contain secrets, proprietary paths, internal error details, or user content that survive into future sessions and may be exposed to the agent or other readers beyond the original context.

Content

Scanner excerpt · hooks/openclaw/HOOK.md (reported line 40)May include surrounding context.

md
## Opt-In and Safety

- The sweep only runs when `<workspace>/.learnings/` exists — create that
  directory to enable it, delete it to disable it
- `ERRORS.md` is created only if missing and is otherwise appended to, never
  overwritten

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 · references/examples.md (reported line 301)May include surrounding context.

When the above learning is extracted as a skill, it becomes:

File: skills/docker-m1-fixes/SKILL.md

markdown
---

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · references/openclaw-integration.md (reported line 68)May include surrounding context.

md
`<workspace>/.learnings/ERRORS.md` (only if `.learnings/` exists — see
  [Error Detection](#error-detection))

### 3. Create Learning Files

Create the `.learnings/` directory in your workspace:

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · references/openclaw-integration.md (reported line 251)May include surrounding context.

bash
# Enable
mkdir -p ~/.openclaw/workspace/.learnings

# Disable (reminder injection keeps working)
rm -r ~/.openclaw/workspace/.learnings

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
84% confidence
Finding

This markdown file includes a 'Detection Triggers' section with generic triggers such as 'Knowledge gaps' and user corrections like 'No, that's wrong...' without clear boundaries for when the skill should activate versus when it should not. Because these phrases overlap with common interactions and no negative examples or tighter scope are given here, the trigger guidance is overly broad for a markdown skill description.

Content

No source excerpt is available for this finding.

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
80% confidence
Finding

Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Content

Scanner excerpt · references/uninstall.md (reported line 11)May include surrounding context.

md
> errors, corrections, and insights the skill captured for you. Review or
> archive it before deleting anything. Content the skill *promoted* into
> `SOUL.md`, `TOOLS.md`, or `AGENTS.md` is part of those files now — removing
> the skill does not (and should not) automatically remove it.

## Disable only

Vague Triggers

Low
Category
Not specified by scanner
Confidence
81% confidence
Finding

The description ends with 'Also review learnings before major tasks,' but does not define what counts as a major task or when this review should occur. That ambiguity can expand invocation beyond the intended failure/correction scenarios described earlier in the same sentence.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Low
Category
Not specified by scanner
Confidence
77% confidence
Finding

The manifest says the hook 'Injects self-improvement reminder at bootstrap and sweeps ended sessions for errors,' while the body explains it also prompts the agent to log corrections, errors, and discoveries and may include triage notes in the injected bootstrap content. That is slightly broader than a mere reminder because it actively alters the initial operating instructions for the agent.

Content

No source excerpt is available for this finding.