T02 · Agent Memory Poisoning
- Location
SKILL.md:333- Finding
Untrusted Learnings Can Poison Persistent Agent Context
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 333-360
Vulnerability Type: Persistent agent-memory poisoning
Risk Level: MediumRelevant supporting locations:
SKILL.md:15-26andSKILL.md:442-448Vulnerable code/documentation segment:
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 Write promoted rules as short prevention rules (what to do before/while coding), not long incident write-ups.The broader workflow also instructs the agent to record user corrections and promotes aggressive persistence:
markdown | User corrects you | Log to `.learnings/LEARNINGS.md` with category `correction` | | Broadly applicable learning | Promote to `CLAUDE.md`, `AGENTS.md`, and/or `.github/copilot-instructions.md` | | Workflow improvements | Promote t ...[truncated 2649 chars]- Remediation
View remediation
Remediation Suggestions
- Require explicit, informed human approval before writing any learning into an automatically loaded agent-context file.
- Treat user prompts, tool output, external documents, task summaries, and sub-agent responses as untrusted provenance.
- Permit automatic promotion only for narrowly scoped, verifiable project facts; prohibit automatic promotion of behavioral rules, security-policy changes, tool-execution directives, credential-handling instructions, or instructions that weaken safeguards.
- Store source metadata with every learning, including the originating task, author, timestamp, and whether the content came from an external or untrusted source.
- Add a review gate that displays the exact proposed diff and destination file before promotion.
- Replace “promote aggressively” with a conservative policy that defaults to retaining entries in
.learnings/until reviewed. - Validate recurrence using independently verified incidents rather than repeated text alone, so an attacker cannot satisfy the threshold by repetition.
- Delimit promoted facts as reference data rather than executable agent instructions, where supported by the host platform.
- Periodically audit persistent context files and provide a documented rollback mechanism for poisoned entries.
