T02 · Agent Memory Poisoning
- Location
capture-learning.sh:101- Finding
Persistent Learning Store Allows Agent Memory Poisoning
- Content
View full analysis
> "$LEARNINGS_FILE" << EOF {"timestamp":"$TIMESTAMP","type":"$TYPE","severity":"$SEVERITY","context":"$CONTEXT","issue":"$ISSUE","correction":"$CORRECTION","lesson":"$LESSON","tags":"$TAGS","taskSlug":"$TASK_SLUG"} EOF ``` The persisted records are subsequently retrieved before future tasks: ```bash # Search for relevant learnings if [[ -x "$SEARCH_SCRIPT" ]]; then echo "📚 Searching for relevant learnings..." echo "" # Search by task type and keywords "$SEARCH_SCRIPT" "$TASK_TYPE $*" --limit 5 echo "" echo "💡 Tip: Review these learnings before starting your task!" echo "" else echo "❌ Search script not found. Make sure the skill is installed." fi ``` ### Technical Analysis The script accepts attacker-influenced values for `context`, `issue`, `correction`, `lesson`, `tags`, and `taskSlug`, then interpolates them directly into a JSONL reco ...[truncated 2373 chars]- Remediation
View remediation
> "$LEARNINGS_FILE" ``` 2. Validate maximum field lengths and reject unexpected control characters where they are not required. 3. Require explicit user approval before writing corrections or behavioral guidance into persistent memory. 4. Record provenance, creation method, author, and trust level for each learning. 5. Treat retrieved records strictly as untrusted data, not executable instructions. 6. Clearly delimit stored records when presenting them to an agent and warn that their contents must not override system or user instructions. 7. Validate every JSONL record before appending it and before consuming it. 8. Use restrictive permissions, such as `umask 077` and file mode `0600`, for the memory directory and learning file. ]]>
