T02 · Agent Memory Poisoning
Error
- Location
- SKILL.md:330
- Finding
- Untrusted Learning Content Can Be Promoted into Persistent Agent Instructions<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:330-365`, `SKILL.md:397-448`, `references/openclaw-integration.md:125-144` **Vulnerability Type**: Persistent agent memory poisoning **Risk Level**: High ### Vulnerable Code and Instructions `SKILL.md:330-365`: ```markdown ### 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 Write promoted rules as short prevention rules (what to do before/while coding), not long incident write-ups. ``` `SKILL.md:397-448`: ```markdown ## Detection Triggers Automatically log when you notice: **Corrections** (→ learning with `correction` category): - "No, that's not right..." - "Actually, it should be..." - "You're wrong about..." - "That's outdated..." **Feature Requests** (→ feature request): - "Can you also..." - "I wish you could..." - "Is there a way to..." - "Why can't you..." **Knowledge Gaps** (→ learning with `knowledge_gap` category): - User provides information you didn't know - Documentation you referenced is outdated - API behavior differs from your understanding **Errors ...[truncated 4566 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Require explicit human approval before writing any learned rule into an agent-context or system-prompt file. 2. Classify learning sources by trust level. User messages, external documents, tool output, task summaries, and cross-session messages must be treated as untrusted. 3. Store observations as quoted data rather than executable instructions. Separate factual evidence from proposed behavioral rules. 4. Reject promotion candidates that: - Attempt to override system or safety constraints. - Modify authorization or approval requirements. - Request secret access or disclosure. - Direct the agent to execute commands or contact external systems. - Contain role-changing or instruction-precedence language. 5. Replace the recurrence-only promotion rule with a review workflow requiring: - Verified provenance. - Independent technical validation. - Maintainer approval. - A documented scope and expiration or review date. 6. Use a strict schema and allowlist for promoted rules. Do not copy arbitrary Markdown directly from conversations into instruction files. 7. Record the original source, approving identity, review timestamp, and exact diff for every promotion. 8. Prevent learned content from overriding system instructions, safety policies, least-privilege controls, or tool authorization boundaries. 9. Add tests using malicious corrections and repeated prompt-injection payloads to verify that they cannot enter persistent context automatically. ]]>
