T02 · Agent Memory Poisoning
Error
- Location
- SKILL.md:22
- Finding
- Untrusted Session Content Can Poison Persistent Agent Instructions<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:22-35, 64-90` **Vulnerability Type**: Persistent memory and instruction poisoning **Risk Level**: High ### Vulnerable Code ```markdown ## Step 2: Read Session History For each interesting session from Step 1, read the JSONL transcript: ```bash # Read the last ~50 lines of each session file (keep it bounded!) tail -50 ~/.openclaw/agents/main/sessions/<sessionId>.jsonl ``` Parse the JSONL to understand what happened. Look for: - `type: "user"` or `type: "human"` — what was asked - `type: "assistant"` — what you responded - `type: "tool_use"` / `type: "tool_result"` — what tools were called and results - Error patterns, retries, confusion ``` ```markdown ## Step 4: Route Insights to the Right Files Each insight belongs somewhere specific. Route them: ### → `AGENTS.md` - Process improvements (how to handle sessions, memory, etc.) - New conventions or workflow rules - Safety lessons ### → `TOOLS.md` - Tool-specific gotchas ("gog needs --json flag for parsing") - Environment details (paths, configs, quirks) - New tool patterns discovered ### → `memory/YYYY-MM-DD.md` (today's date) - Session-specific context ("Brenner asked about X project") - Temporary facts that matter today but not forever - What happened today (events, decisions, requests) ### → `memory/about-user.md` - New preferences discovered - Communication style observations - Project/interest updates ### → `skills/<skill-name>/SKILL.md` - Improvements to specific skill instructions - Bug fixes in skill workflows - New parameters or approaches for a skill ### → `MEMORY.md` - Updates to the memory index if new memory files are created ``` ### Technical Analysis The Skill treats user-controlled transcript content as source material for persistent operational rules. It then directs the Agent to write derived insights into high-trust files such as `AGENTS.md`, `TOOLS.md`, `MEMORY.md`, and other `SKILL.md` files. The documented qualit ...[truncated 1947 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Treat every session transcript as untrusted data, regardless of whether it came from a direct or group conversation. 2. Prohibit automatic modifications to `AGENTS.md`, `TOOLS.md`, `MEMORY.md`, and all `SKILL.md` files based solely on transcript content. 3. Write proposed insights to a dedicated quarantine or review file that is never loaded as Agent instructions. 4. Require explicit workspace-owner approval before promoting any proposed insight into persistent instruction files. 5. Attach provenance metadata to every proposal, including the session key, message identifier, author type, timestamp, and exact supporting excerpt. 6. Reject proposals that contain behavioral directives, safety-policy changes, commands, URLs, credential material, requests to weaken validation, or instructions to modify tools and Skills. 7. Allow automatic persistence only for narrowly structured, non-executable factual notes after sensitive-data filtering. 8. Separate group-session and external-user content from owner-authorized content, and deny group participants the ability to influence persistent rules. 9. Add a security review step that evaluates whether an insight expands permissions, changes trust boundaries, or affects future tool execution. ]]>
