Back to skill

Security audit

self-improving-agent

Security checks for vulnerabilities and agentic risk

Overview

This skill is mostly transparent about logging learnings, but it can persist conversation-derived content into future agent guidance and its optional hook can automatically influence later sessions.

Install only if you intentionally want durable agent self-improvement logs and are comfortable with an optional hook that affects future OpenClaw sessions. Keep .learnings out of version control, review entries before promotion, require explicit approval before writing to SOUL.md/TOOLS.md/AGENTS.md, and avoid enabling the hook in workspaces containing sensitive transcripts until transcript path containment and retention controls are tightened.

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

T01 · Skill Instruction Hijacking

Error
Location
hooks/openclaw/handler.ts:379
Finding

Persistent Behavioral Instruction Injection Through the OpenClaw Bootstrap Hook

Content
View full analysis
{ // Skip sub-agent sessions to avoid bootstrap issues // Sub-agents have sessionKey patterns like "agent:main:subagent:..." const sessionKey = event.sessionKey || ''; if (sessionKey.includes(':subagent:')) { return; } const context = event.context as Record; // Inject the reminder as a virtual bootstrap file // Check that bootstrapFiles is an array before pushing if (!Array.isArray(context.bootstrapFiles)) { return; } const occupiedByOtherFile = context.bootstrapFiles.some( (file) => isObject(file) && file.path === REMINDER_PATH && !isInjectedReminderFile(file), ); if (occupiedByOtherFile) { return; } let reminderContent = REMINDER_CONTENT; const workspaceDir = typeof context.workspaceDir === 'string' && context.workspaceDir.trim() ? context.workspaceDir : undefined; const pendingSweepCount = await countPendingSweepEntries(workspaceDir); if (pendingSweepCount > 0) { const plural = pendingSweepCount === 1 ? 'y' : 'ies'; reminderContent += `\n\n**Pending triage:** ${pendingSweepCount} auto-detected error entr${plural} ` + `(Source: ${SWEEP_SOURCE}) in \`.learnings/ERRORS.md\` await review. ` + 'Confirm, resolve, or delete them when convenient.'; } const cleanedBootstrapFiles = context.bootstrapFiles.filter( (file, index, files) => !isInjectedReminderFile(file) || files.findIndex((candidate) => isInjectedReminderFile(candidate)) === index, ); const reminderFile = { name: REMINDER_NAME, path: REMINDER_PATH, content: reminderContent, missing: false, virtual: true, }; const existingIndex = cleanedBootstrapFiles.findIndex((file) => ...[truncated 2413 chars]
Remediation
View remediation

T02 · Agent Memory Poisoning

Error
Location
SKILL.md:394
Finding

Conversation-Derived Content Can Be Promoted Into Persistent Agent Guidance

Content
View full analysis
= 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. ``` The broader best-practice instructions additionally state: ```markdown ## Best Practices 1. **Log immediately** - context is freshest right after the issue 2. **Be specific** - future agents need to understand quickly 3. **Include reproduction steps** - especially for errors 4. **Link related files** - makes fixes easier 5. **Suggest concrete fixes** - not just "investigate" 6. **Use consistent categories** - enables filtering 7. **Promote aggressively** - if in doubt, add to `TOOLS.md` or `SOUL.md` 8. **Review regularly** - stale learnings lose value ``` ### Technical Analysis The Skill treats user corrections, task summaries, command output, and inferred recurring patterns as candidate learning material. It then directs the agent to convert qualifying material into `SOUL.md`, `TOOLS.md`, `AGENTS.md`, or a project-specific agent file. These files are described as persistent behavioral, tool, and workflow guidance loaded into later sessions. Consequently, content originating in an untrusted conversation can cross a trust boundary from temporary task input into durable agent instructions. The recurrence criteria provide some resistance to one-off input, but recurrence count is not a security or truth validation mechanism. An attacker can repeat the s ...[truncated 1689 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
hooks/openclaw/handler.ts:220
Finding

Unvalidated Session Transcript Path Permits Arbitrary Local JSONL File Reads

Content
View full analysis
, workspaceDir: string | undefined, ): string | undefined { const sessionEntry = isObject(context.previousSessionEntry) ? context.previousSessionEntry : isObject(context.sessionEntry) ? context.sessionEntry : {}; const sessionFile = (sessionEntry as Record).sessionFile; if (typeof sessionFile === 'string' && sessionFile.trim()) { return sessionFile; } const sessionIdValue = (sessionEntry as Record).sessionId; const sessionId = typeof sessionIdValue === 'string' ? sessionIdValue.trim() : ''; if (sessionId && workspaceDir) { return path.join(workspaceDir, 'sessions', `${sessionId}.jsonl`); } return undefined; } ``` The returned path is passed directly to the transcript scanner: ```typescript async function scanTranscriptForErrors(sessionFilePath: string): Promise { let raw: string; try { raw = await fs.readFile(sessionFilePath, 'utf-8'); } catch { return []; } const excerpts: SweepExcerpt[] = []; const seen = new Set(); for (const jsonLine of raw.split('\n')) { if (excerpts.length >= MAX_EXCERPTS) { break; } const trimmed = jsonLine.trim(); if (!trimmed) { continue; } let entry: unknown; try { entry = JSON.parse(trimmed); } catch { continue; } if (!isObject(entry) || !isObject(entry.message)) { continue; } const fragments: string[] = []; collectTextFragments(entry.message.content, fragments); for (const fragment of fragments) { for (const line of fragment.split('\n')) { const patternKey = matchErrorPatternKey ...[truncated 2918 chars]
Remediation
View remediation
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Rogue AgentSelf-Modification, Session Persistence
Findings (25)

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

The declared description says this skill is for recording learnings, failures, corrections, and outdated knowledge to improve future behavior. The supplied code does something materially different: it creates a new skill scaffold from a skill name by making directories and writing a templated SKILL.md file. While the template references a 'source learning,' the script itself does not capture learnings, parse corrections, review prior learnings, or handle failure/improvement workflows. Its primary purpose is skill extraction/scaffolding, not continuous-improvement logging or review. Therefore the description does not accurately represent the code's actual behavior.

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

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 · CHANGELOG.md (reported line 135)May include surrounding context.

md
### Upgrade notes (0.1.x → 0.2.0)

1. Re-copy the hook and restart the gateway (see general rules above).
2. To enable the new error sweep: `mkdir -p ~/.openclaw/workspace/.learnings`.
   Without that directory, behavior is identical to 0.1.0.
3. No breaking changes; no `.learnings/` migration needed.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill instructs the agent to run shell commands, create files under the workspace/home directory, clone/copy from GitHub, and use session-sharing features, but it declares no explicit tool scope or allowed-tools constraints. In systems that honor skill-declared permissions, this can cause the skill to operate with whatever ambient filesystem/network/tool access the host grants, increasing the blast radius if the skill is invoked unexpectedly or modified later.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The description says to use the skill when a user corrects the agent and includes examples like 'Actually...' and similar phrasing. These are common everyday utterances, and the trigger scope does not clearly distinguish casual conversation from moments that should invoke this skill, which can lead to unintended activation.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
89% confidence
Finding

The skill explicitly establishes persistent storage in ~/.openclaw/workspace/.learnings and encourages promotion of content into durable workspace memory files inherited by future sessions. Even with cautions against logging secrets, this creates a cross-session retention channel where sensitive user content, error output, internal paths, or corrected information may persist longer than intended and influence future agent behavior.

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

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 · 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
85% confidence
Finding

This hook persists excerpts from prior session transcripts into .learnings/ERRORS.md, creating cross-session retention of operational data. Even with truncation and redaction, transcript excerpts can still contain sensitive commands, filenames, internal paths, prompts, or partially unredacted secrets, and the file is explicitly append-only and long-lived, increasing exposure and discoverability.

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:

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The documentation describes scanning prior session transcripts and appending excerpts into persistent learning files, but the privacy implications are only discussed later and not prominently disclosed before setup. Because transcripts may contain secrets, personal data, or internal outputs, this can lead to unintentional retention of sensitive information even with best-effort redaction.

Content

No source excerpt is available for this finding.

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
88% confidence
Finding

The 'Standard Triggers' section lists broad conditions such as 'User corrections', 'API errors', and 'Knowledge gaps' without defining boundaries or exclusions. In a markdown skill guide, this can create ambiguous activation expectations about when the skill should engage or log learnings versus when it should not.

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
78% confidence
Finding

The phrase 'Also review learnings before major tasks' does not define what qualifies as a 'major task' or when this review is expected. That ambiguity can cause inconsistent or overly broad invocation behavior.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.