T02 · Agent Memory Poisoning
Error
- Location
- SKILL.md:502
- Finding
- Unsanitized External Content Can Poison Persistent Agent Memory<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 207-259 and 502-577; related automatic-loading recommendation in `README.md`, lines 190-196 **Vulnerability Type**: Persistent storage of untrusted, instruction-like model output **Risk Level**: High ### Vulnerable Code Snippets `SKILL.md`, lines 207-259: ```markdown #### Source 3: book-scout Web Search When the queue is empty and the user has not specified a book, invoke the `book-scout` skill. ... Invoke book-scout: Topic: {topic} Previously read books: - "The Lean Startup" - "Zero to One" - "Influence" Run the book-scout skill and search for a classic book matching the topic. ``` `SKILL.md`, lines 502-577: ```markdown For Thinking Patterns / Principles, write to: `memory/knowledge-base/patterns/{id}.md` Extract frontmatter fields from the `KB_META` block returned by `mental-model-forge`, and map FACET dimensions into body fields: --- id: {from KB_META} name_zh: {from KB_META} name_en: {from KB_META} source: {book_title}, {author} category: {from KB_META} tags: {from KB_META} scenarios: {from KB_META} related_models: {from KB_META} difficulty: {from KB_META} date: YYYY-MM-DD --- **Core Logic**: {A paragraph refined from [F] Core Framework} **Thinking Framework**: {Use the [F] Core Framework content directly} **Decision Principle**: {Derived from [F] and [E]} **Blind-Spot Warning**: {Use the [E] Hidden Boundaries content directly} **Reflex Trigger**: {Derived from scenarios} **Anchor Case**: {Use the [A] Anchor Case content directly} **Contrarian Insight**: {Use the contradiction field from KB_META} ``` `README.md`, lines 190-196: ```markdown ## Session Startup 1. Read `SOUL.md` — this is who you are 2. Read `USER.md` — this is who you're helping 3. Read `memory/YYYY-MM-DD.md` (today + yesterday) for recent context 4. **Load `memory/knowledge-base/thinking-patterns.md`** — your decision frameworks ``` ### Technical Analysis The workflow creates a persistent trust-bou ...[truncated 2504 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Treat all search results, dependency responses, FACET fields, and `KB_META` values as untrusted data. 2. Add a security-validation stage before every persistent write. Reject or quarantine content containing: - Role or policy changes. - Requests to ignore previous instructions. - Tool-use or command-execution directives. - Requests to read, disclose, upload, or modify unrelated data. - Encoded, hidden, or externally loaded instructions. 3. Store generated material as explicitly delimited quoted data, not as instructions for the Agent. 4. Add provenance fields recording the source URL, dependency, timestamp, and review state. 5. Require explicit user approval before first-time or externally sourced content enters the persistent knowledge base. 6. Separate trusted decision frameworks from unreviewed generated entries. Do not automatically load unreviewed entries at session startup. 7. When loading knowledge entries, apply a higher-priority instruction stating that entries are untrusted reference material and cannot authorize tool calls, policy changes, or data access. 8. Validate YAML and Markdown structure and escape control syntax, embedded frontmatter delimiters, HTML comments, links, and other instruction-hiding mechanisms. 9. Add tests containing representative indirect prompt-injection payloads and verify that they are rejected or safely quarantined. ]]>
