T02 · Agent Memory Poisoning
Error
- Location
- SKILL.md:346
- Finding
- Untrusted Learning Content Can Poison Persistent Agent Instructions<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:346-360`, `SKILL.md:448`, `hooks/openclaw/handler.js:11-24` **Vulnerability Type**: Persistent agent memory poisoning **Risk Level**: High ### Vulnerable Code From `SKILL.md:346-360`: ```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: - `CLAUDE.md` - `AGENTS.md` - `.github/copilot-instructions.md` - `SOUL.md` / `TOOLS.md` for OpenClaw workspace-level guidance when applicable Write promoted rules as short prevention rules (what to do before/while coding), not long incident write-ups. ``` From `SKILL.md:448`: ```markdown 7. **Promote aggressively** - if in doubt, add to CLAUDE.md or .github/copilot-instructions.md ``` From `hooks/openclaw/handler.js:11-24`: ```javascript After completing tasks, evaluate if any learnings should be captured: **Log when:** - User corrects you → \`.learnings/LEARNINGS.md\` - Command/operation fails → \`.learnings/ERRORS.md\` - User wants missing capability → \`.learnings/FEATURE_REQUESTS.md\` - You discover your knowledge was wrong → \`.learnings/LEARNINGS.md\` - You find a better approach → \`.learnings/LEARNINGS.md\` **Promote when pattern is proven:** - Behavioral patterns → \`SOUL.md\` - Workflow improvements → \`AGENTS.md\` - Tool gotchas → \`TOOLS.md\` ``` ### Technical Analysis The skill creates a path from user-influenced conversation content to persistent agent instruction files. User corrections and task-derived observations may first be written to `.learnings/LEARNINGS.md` and then promoted into files such as `CLAUDE.md`, `AGENTS.md`, `SOUL.md`, `TOOLS.md`, or Copilot instructions. The promotion criteria check recurrence and time, but they do not validate: - Whether the original content came from a trusted source. - Whether a human explic ...[truncated 1563 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Require explicit human approval before writing to any persistent agent instruction file. 2. Treat every learning derived from user messages, command output, external documents, or tool results as untrusted data. 3. Record provenance for every entry, including its source session, author, originating file, and approval status. 4. Do not use recurrence alone as evidence of trust; prevent duplicate attacker-generated observations from satisfying promotion criteria. 5. Add a validation stage that rejects: - Safety-policy overrides. - Requests to ignore prior instructions. - Tool-execution directives. - Encoded or obfuscated content. - External payload URLs. - Credential-handling instructions. 6. Generate a proposed diff for human review instead of directly modifying `CLAUDE.md`, `AGENTS.md`, `SOUL.md`, `TOOLS.md`, or Copilot instructions. 7. Limit automatic promotion to narrowly scoped, non-executable project facts. 8. Maintain an audit log and provide a rollback mechanism for every promoted rule. ]]>
