T02 · Agent Memory Poisoning
- Location
- scripts/memory.sh:73
- Finding
- Untrusted Conversation Content Can Poison Persistent Agent Memory## Vulnerability Details **File Location**: `README.md:22-40`, `README.md:43-58`, `scripts/memory.sh:73-80`, `scripts/memory.sh:116-133` **Vulnerability Type**: Persistent storage of untrusted agent input without provenance or instruction filtering **Risk Level**: High ### Vulnerable Code `README.md:22-40` directs the agent to record information after every interaction: ```markdown ## Feature 1: Auto-Memory ### Trigger Timing - After each user interaction - After completing an action ### Recording Rules | Type | Recording Method | Example | |------|------------------|---------| | Normal Information | Concise summary | "User requested to check installed skills" | | Important Information | Detailed record | User requirements, solutions, scheduled task creation | ### Execution Commands ```bash # Record normal information ./scripts/memory.sh record "Conversation summary" --type normal # Record important information ./scripts/memory.sh record "Detailed record..." --type important --tags "requirements,stocks" ``` ``` `README.md:43-58` directs future agent activity to retrieve and act on persisted memories: ```markdown ## Feature 2: Double Check ### Trigger Timing 1. **Automatic Trigger**: Before each delivery 2. **Manual Trigger**: User says "double check"/"dc it" ### Execution Flow 1. Retrieve relevant memories (`memory/`) 2. Compare current task with user requirements 3. Determine if requirements are met 4. If not met, identify reasons and correct ### Execution Command ```bash ./scripts/memory.sh check "Current task description" "User original requirements" ``` ``` `scripts/memory.sh:73-80` appends caller-controlled content to the persistent diary: ```bash entry="$entry\n\n$content" # Append the constructed entry to the persistent diary. echo -e "$entry" >> "$diary_file" # Update the index using the same caller-controlled content and tags. update_index "daily/ ...[truncated 2887 chars]
- Remediation
- ## Remediation Suggestions 1. Store memories as structured records containing source, user identity, task identifier, timestamp, trust level, and data type. 2. Treat all recalled memory as untrusted reference data. Never place it in a system-instruction or developer-instruction context. 3. Reject or quarantine memory entries containing imperative instructions, role changes, tool directives, credential requests, or attempts to override policies. 4. Require explicit user approval before promoting diary entries into long-lived experience or policy records. 5. Separate factual memories from preferences, instructions, and learned policies using different stores and access controls. 6. Limit retrieval to the current user and project, and display provenance when recalled content is presented to the agent. 7. Replace keyword-only reflection with a validation process that confirms relevance, authenticity, and safety. 8. Provide a review, correction, and deletion mechanism for poisoned or obsolete memory records.
