T02 · Agent Memory Poisoning
Error
- Location
- references/files-universal-interface.md:91
- Finding
- Persistent User-Editable Context Can Poison Future Agent Sessions<![CDATA[ ## Vulnerability Details **File Location**: `references/files-universal-interface.md:91-136` **Vulnerability Type**: Persistent instruction and memory poisoning **Risk Level**: High ### Vulnerable Code ```markdown ## The context.md Pattern A file the agent reads at the start of each session and updates as it learns: # Context ## Who I Am Reading assistant for the Every app. ## What I Know About This User - Interested in military history and Russian literature - Prefers concise analysis - Currently reading War and Peace ## What Exists - 12 notes in /notes - 3 active projects - User preferences at /preferences.md ## Recent Activity - User created "Project kickoff" (2 hours ago) - Analyzed passage about Austerlitz (yesterday) ## My Guidelines - Don't spoil books they're reading - Use their interests to personalize insights ## Current State - No pending tasks - Last sync: 10 minutes ago ``` ```markdown ### Benefits - **Agent behavior evolves without code changes** - Update the context, behavior changes - **Users can inspect and modify** - Complete transparency - **Natural place for accumulated context** - Learnings persist across sessions - **Portable across sessions** - Restart agent, knowledge preserved ### How It Works 1. Agent reads `context.md` at session start 2. Agent updates it when learning something important 3. System can also update it (recent activity, new resources) 4. Context persists across sessions ``` ### Technical Analysis The recommended persistent file combines behavioral instructions—such as agent identity and guidelines—with user data and runtime state. It is also explicitly user-editable and automatically loaded at the start of future sessions. No required mechanism separates trusted policy from untrusted learned data. The pattern does not require authenticated writes, provenance tracking, a typed schema, content validation, or approval before persistent guidelines are changed. Consequently, text inserted by a use ...[truncated 1461 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Keep agent identity, safety policy, authorization rules, and tool-use constraints in immutable, developer-controlled configuration. - Store learned user information in a typed data structure whose fields cannot introduce executable instructions. - Separate persistent state into distinct trust domains, such as `trusted_policy`, `user_preferences`, `observations`, and `pending_tasks`. - Record the source, author, timestamp, and confidence of each learned item. - Require authenticated, content-bound approval before modifying any persistent behavioral rule. - Treat all user-editable and synchronized content as data, never as developer instructions. - Validate and sanitize memory updates before persistence, and reject instruction-like content in data-only fields. - Provide revision history, rollback, integrity checks, and an audit log for persistent-memory changes. ]]>
