T02 · Agent Memory Poisoning
Warning
- Location
- SKILL.md:328
- Finding
- Untrusted learning content can persistently influence future agent sessions<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:328-360`; supporting behavior in `hooks/openclaw/handler.js:20-23` and `references/openclaw-integration.md:130-142` **Vulnerability Type**: Persistent agent memory poisoning **Risk Level**: Medium ### Vulnerable Code ```markdown ## Simplify & Harden Feed Use this workflow to ingest recurring patterns from the `simplify-and-harden` skill and turn them into durable prompt guidance. ### Ingestion Workflow 1. Read `simplify_and_harden.learning_loop.candidates` from the task summary. 2. For each candidate, use `pattern_key` as the stable dedupe key. 3. Search `.learnings/LEARNINGS.md` for an existing entry with that key: - `grep -n "Pattern-Key: <pattern_key>" .learnings/LEARNINGS.md` 4. If found: - Increment `Recurrence-Count` - Update `Last-Seen` - Add `See Also` links to related entries/tasks 5. If not found: - Create a new `LRN-...` entry - Set `Source: simplify-and-harden` - Set `Pattern-Key`, `Recurrence-Count: 1`, and `First-Seen`/`Last-Seen` ### 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 ``` The OpenClaw bootstrap hook reinforces the promotion workflow: ```javascript **Promote when pattern is proven:** - Behavioral patterns → \`SOUL.md\` - Workflow improvements → \`AGENTS.md\` - Tool gotchas → \`TOOLS.md\` ``` ### Technical Analysis The Skill accepts information originating from user corrections, task summaries, errors, and session activity, stores it in `.learnings/`, and encourages promotion into files that function as persistent agent instructions. Recurrence counting establishes frequency but not trustworthiness. The wo ...[truncated 2376 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Require explicit human approval before promoting any learning into an automatically loaded instruction file. 2. Treat user messages, command output, task summaries, session transcripts, and generated learning entries as untrusted data. 3. Store learnings in a non-authoritative data file rather than directly in `SOUL.md`, `AGENTS.md`, `TOOLS.md`, or equivalent instruction files. 4. Preserve provenance for every entry, including originating user, session, task, timestamp, and approval status. 5. Reject or quarantine content that: - Contains imperative commands. - Changes safety or authorization requirements. - Requests secret access or external transmission. - Modifies tool permissions or confirmation rules. - Instructs the agent to ignore higher-priority guidance. 6. Replace frequency-only promotion with a review process that evaluates correctness, security impact, and source trust. 7. Delimit any stored learning injected into context as untrusted reference material and explicitly prohibit treating it as an instruction. 8. Provide a review and rollback mechanism for all promoted rules. 9. Restrict cross-session propagation to sanitized factual summaries rather than verbatim session-derived content. ]]>
