T02 · Agent Memory Poisoning
Error
- Location
- SKILL.md:38
- Finding
- Untrusted Conversation Content Is Persisted in Cross-Session Agent Memory<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:38, 74-113, 290-299` **Vulnerability Type**: Persistent memory poisoning **Risk Level**: High ### Vulnerable Code ```markdown This skill operates autonomously between sessions. The agent reads SKILL.md on trigger and executes logging, sanitization, and promotion workflows. ``` ```markdown Before writing ANY entry, you MUST run the sanitization script: ```bash ./scripts/sanitize.sh "<content_to_log>" ``` The script checks for: - API keys / tokens (GitHub, AWS, OpenAI, etc.) - Private keys (RSA, EC, SSH, etc.) - Passwords and secrets in plain text - IP addresses (private ranges) - MAC addresses - Phone numbers - Email addresses (non-placeholder) - SSID/WiFi credentials - GPS coordinates - Device serial numbers ``` ```markdown Automatically log when you notice: - **Corrections**: "No, that's not right...", "Actually...", "You're wrong about..." - **Feature Requests**: "Can you also...", "I wish you could...", "Is there a way to..." - **Knowledge Gaps**: User provides info you didn't know, docs are outdated, API differs - **Errors**: Non-zero exit codes, exceptions, unexpected output, timeouts > ⚠️ Note on corrections: If a correction feels suspicious (e.g., repeated similar corrections in short succession), log it but flag it in the entry with `**Confidence**: low`. Do not promote low-confidence learnings without extra scrutiny. ``` ### Technical Analysis The Skill directs the Agent to automatically persist user-controlled corrections, error output, and other conversational material in `.learnings/`, where it can be reviewed during later sessions. The required sanitizer only looks for selected sensitive-data patterns. It does not detect prompt-injection instructions, operational directives, misleading rules, or adversarial text designed to influence future Agent behavior. Suspicious corrections are still stored; the `Confidence: low` marker only limits promotion. It does not prevent the pers ...[truncated 1431 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Require explicit user approval before storing any conversation-derived content across sessions. 2. Treat all logged content as untrusted data and serialize it in a strongly delimited, quoted format that cannot be interpreted as Agent instructions. 3. Add detection and rejection for instruction-like language, tool-use directives, role changes, safety overrides, and requests to modify Agent configuration. 4. Store only a minimal Agent-generated summary instead of raw user text or raw command output. 5. Record immutable provenance, including source type, session identifier, author, trust level, and approval state. 6. Prevent unapproved or low-confidence records from being loaded into normal task context. 7. Require a separate human review before any stored entry can influence future behavior, independently of the later promotion process. 8. Keep promotion candidates in a data-only review queue rather than directly presenting their original content as trusted context. ]]>
