T02 · Agent Memory Poisoning
Error
- Location
- SKILL.md:16
- Finding
- Untrusted conversation content can be promoted into persistent agent instructions<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:16-25`, `SKILL.md:243-279`, `SKILL.md:393-400`, `hooks/openclaw/handler.js:8-27`, `hooks/openclaw/handler.js:46-51` **Vulnerability Type**: Persistent agent memory poisoning **Risk Level**: High ### Vulnerable Code `SKILL.md:16-25`: ```markdown | User corrects you | Log to `.learnings/LEARNINGS.md` with category `correction` | | User wants missing feature | Log to `.learnings/FEATURE_REQUESTS.md` | | API/external tool fails | Log to `.learnings/ERRORS.md` with integration details | | Knowledge was outdated | Log to `.learnings/LEARNINGS.md` with category `knowledge_gap` | | Found better approach | Log to `.learnings/LEARNINGS.md` with category `best_practice` | | Similar to existing entry | Link with `**See Also**`, consider priority bump | | Broadly applicable learning | Promote to `CLAUDE.md`, `AGENTS.md`, and/or `.github/copilot-instructions.md` | | Workflow improvements | Promote to `AGENTS.md` (OpenClaw workspace) | | Tool gotchas | Promote to `TOOLS.md` (OpenClaw workspace) | | Behavioral patterns | Promote to `SOUL.md` (OpenClaw workspace) | ``` `SKILL.md:393-400`: ```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 CLAUDE.md or .github/copilot-instructions.md 8. **Review regularly** - stale learnings lose value ``` `hooks/openclaw/handler.js:46-51`: ```javascript if (Array.isArray(event.context.bootstrapFiles)) { event.context.bootstrapFiles.push({ path: 'SELF_IMPROVEMENT_REMINDER.md', content: REMINDER_CONTENT, virtual: true, }); } ``` ### Technical Analysis The skill directs the agent to derive learni ...[truncated 2029 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the “promote aggressively” guidance. 2. Require explicit human approval before modifying persistent instruction files. 3. Present a reviewable diff showing the exact source and destination text. 4. Record provenance for every learning, including session, user, source file, and timestamp. 5. Treat user messages, command output, API responses, and repository documents as untrusted data. 6. Reject entries containing imperative agent instructions, requests to weaken safeguards, credential-handling rules, or commands unrelated to verified project facts. 7. Restrict automatic promotion to concise, factual, project-specific metadata. 8. Add allowlists for permitted destination files and sections. 9. Maintain backups and provide a rollback command for promoted entries. 10. Keep the bootstrap hook disabled by default and clearly display when persistent learning behavior is active. ]]>
