T02 · Agent Memory Poisoning
Error
- Location
- SKILL.md:346
- Finding
- Conversation-Derived Rules Can Poison Persistent Agent Context<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:346-360`, `SKILL.md:443-448`, `hooks/openclaw/handler.ts:21-24`, `hooks/openclaw/handler.ts:54-59` **Vulnerability Type**: Persistent agent memory poisoning **Risk Level**: High ### Vulnerable Code `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. ``` `SKILL.md:443-448`: ```markdown 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 ``` `hooks/openclaw/handler.ts:21-24`: ```typescript **Promote when pattern is proven:** - Behavioral patterns → \`SOUL.md\` - Workflow improvements → \`AGENTS.md\` - Tool gotchas → \`TOOLS.md\` ``` `hooks/openclaw/handler.ts:54-59`: ```typescript event.context.bootstrapFiles.push({ path: 'SELF_IMPROVEMENT_REMINDER.md', content: REMINDER_CONTENT, virtual: true, }); ``` ### Technical Analysis The skill instructs the agent to capture corrections, discoveries, and other conversation-derived information and later promote those entries into persistent agent instruction files such as `CLAUDE.md`, `AGENTS.md`, `SOUL.md`, `TOOLS.md`, and `.github/copilot-instructions.md`. These files can be loaded as trusted context in future sessions. The promotion process does not def ...[truncated 3173 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. **Require explicit owner approval** - Never promote conversation-derived content automatically. - Present the proposed destination, source, and exact diff to an authorized user. - Require an explicit confirmation before modifying persistent instruction files. 2. **Track provenance and trust** - Record who supplied each learning, the originating session, timestamp, and whether it was independently verified. - Mark user assertions as untrusted until corroborated by authoritative project documentation or test results. - Prohibit promotion of entries with unknown or untrusted provenance. 3. **Create a strict promotion allowlist** - Permit only concise, declarative project facts and verified workflow constraints. - Reject instruction overrides, shell commands, external upload destinations, authentication instructions, encoded content, and requests to suppress disclosure or review. - Do not promote secrets, credentials, personal information, raw tool output, or complete user messages. 4. **Separate knowledge from agent policy** - Keep descriptive learnings in a non-executable knowledge store. - Do not copy untrusted text directly into files treated as system or bootstrap instructions. - Generate any promoted rule from a fixed, security-reviewed template. 5. **Replace recurrence with verification** - Do not treat repetition as evidence of correctness. - Require reproducible tests, authoritative documentation, or approval from a designated maintainer. - Remove the “promote aggressively” instruction. 6. **Limit write scope** - Restrict the skill to `.learnings/` by default. - Place persistent agent-context files outside the skill’s writable scope where supported. - Use least-privilege filesystem permissions and repository review controls. 7. **Add audit and rollback controls** - Commit persistent-context changes separately with their source learning ID. - Keep an append ...[truncated 362 chars]
