T02 · Agent Memory Poisoning
- Location
scripts/memory.sh:73- Finding
Untrusted Conversation Content Can Poison Persistent Agent Memory
- Content
View full analysis
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: HighVulnerable Code
README.md:22-40directs 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"text `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"text `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
View remediation
Remediation Suggestions
- Store memories as structured records containing source, user identity, task identifier, timestamp, trust level, and data type.
- Treat all recalled memory as untrusted reference data. Never place it in a system-instruction or developer-instruction context.
- Reject or quarantine memory entries containing imperative instructions, role changes, tool directives, credential requests, or attempts to override policies.
- Require explicit user approval before promoting diary entries into long-lived experience or policy records.
- Separate factual memories from preferences, instructions, and learned policies using different stores and access controls.
- Limit retrieval to the current user and project, and display provenance when recalled content is presented to the agent.
- Replace keyword-only reflection with a validation process that confirms relevance, authenticity, and safety.
- Provide a review, correction, and deletion mechanism for poisoned or obsolete memory records.
