T02 · Agent Memory Poisoning
- Location
SKILL.md:25- Finding
Untrusted Conversation Content Can Be Persisted into Long-Term Agent Memory
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 25–40, 50–63, 92–114, and 166–193
Vulnerability Type: Persistent memory poisoning through unsanitized conversation extraction
Risk Level: HighVulnerable Code Snippets
markdown Step 1 — Determine the scope of the current conversation Read the latest messages from the current session and determine the start and end ↓ Step 2 — Identify content worth extracting Scan messages and identify: user decisions / user preferences / project constraints / external-system references ↓ Step 3 — Classify into four types Assign each item a type (user/feedback/project/reference) feedback must include Why + How to apply ↓ Step 4 — Check topics/ for duplicates grep existing topics and confirm no duplicate before writing ↓ Step 5 — Write to a topic file (APPEND, do not overwrite) Format: frontmatter + body ↓ Step 6 — Update the MEMORY.md index Add a one-line pointer (≤150 characters)markdown Read the latest messages from the current session without limiting the number of messages, ensuring that the complete conversation is covered.markdown | External-system reference | URL, tool, account, path | "It is in Linear" |markdown ## Step 5 — Write to a topic file **Format (frontmatter)**: ```yaml --- name: Name description: One-sentence description used to determine relevance type: user / feedback / project / reference --- Body content **Why:** Reason, required for feedback/project **How to apply:** When it applies, required for feedback/projectWrite mode: APPEND; do not overwrite existing content.
Step 6 — Update the MEMORY.md index
Append a pointer to the end of MEMORY.md:
text - [Name](topics/filename.md) — one-sentence hook (≤150 characters)text ```mark ...[truncated 3430 chars]- Remediation
View remediation
Remediation Suggestions
- Require explicit user confirmation before writing any extracted item to persistent memory. Present a preview that includes the exact content, classification, destination file, and rationale.
- Treat all conversation-derived text as untrusted data. Reject or quarantine content containing commands, imperative instructions, attempts to alter agent policy, tool-use directives, encoded payloads, or requests to ignore higher-priority instructions.
- Apply a strict schema that permits factual preferences, decisions, and references but prohibits executable or policy-like instructions. Store structured fields rather than unrestricted prose wherever possible.
- Record provenance for every entry, including session identifier, source message, timestamp, author, extraction method, and approval status. Future agents should be instructed to treat entries as claims rather than authoritative system instructions.
- Limit extraction to the active task and a bounded message window instead of reading an unlimited conversation history.
- Exclude secrets, authentication material, account identifiers, private URLs, and sensitive filesystem paths by default. Add secret and personal-data detection before persistence.
- Separate reference data from behavioral instructions and ensure retrieved memories cannot supersede system, developer, security, or current user instructions.
- Provide deletion, expiration, rollback, and review mechanisms. Avoid unconditional append-only storage for entries that have not been validated.
- Perform deduplication only after safety validation; duplicate detection must not be treated as a security control.
- Disable automatic heartbeat and conversation-end persistence by default, or restrict automatic operation to generating an uncommitted draft that requires approval.
