T02 · Agent Memory Poisoning
Error
- Location
- prompts/l3-weekly-prompt.md:104
- Finding
- Untrusted Conversation Content Can Poison Persistent Agent Rules<![CDATA[ ## Vulnerability Details **File Location**: `prompts/l3-weekly-prompt.md:104-132` **Supporting Locations**: `prompts/l1-hourly-prompt.md:32-33, 43-65, 104-108`; `prompts/migrate-prompt.md:60-76, 95-124` **Vulnerability Type**: Persistent memory poisoning **Risk Level**: Critical ### Vulnerable Code ```markdown ### Step 2: 读取 L2 文件 使用 `read` 工具读取本周所有 memory 文件。 ### Step 3: 识别候选经验 扫描包含以下关键词的内容: - "修复"、"解决"、"发现"、"意识到" - "错误"、"失败"、"崩溃"、"丢失" - "决策"、"选择"、"方案"、"结论" - "最佳实践"、"方法论"、"规则" ### Step 4: 提炼 CAR 格式 对每个候选经验: 1. 提取 Context(触发场景) 2. 提取 Action(失效/成功动作) 3. 提炼 Result(强制复用规则) 4. 确保格式符合 CAR 规范 ### Step 4.5: 去重检查 **读取 `${MEMORY_MD}` 已有内容**,对比每条新提炼法则的核心论点: - 如已有相同或高度相似的核心论点 → 跳过,不重复写入 - 如是新法则 → 继续 ### Step 5: 写入 MEMORY.md 追加到 `${MEMORY_MD}` 末尾: ``` The persistent output template includes: ```markdown - **强制复用规则**:... ``` ### Technical Analysis Session conversations are attacker-influenced input. The hourly L1 process scans those conversations and stores keyword-matched material. The nightly L2 process archives it, and the weekly L3 process converts it into persistent rules described as mandatory for future reuse. There is no provenance tracking, trust classification, instruction-versus-data separation, prompt-injection filtering, authenticated marker validation, or user approval before `MEMORY.md` is changed. Deduplication only compares semantic similarity and does not determine whether a proposed rule is trustworthy. The migration process exposes the same condition by deriving L3 rules from historical backup content without validating the origin or safety of that content. ### Attack Path 1. An attacker submits conversation text containing terms recognized by L1 or L3, such as a decision, rule, solution, or best practice. 2. The hourly task reads the affected session log and extracts the crafted material into `SESSION-STATE.md`. 3. The nightly task copies the extracted material into an L2 archive. 4. The weekly task interprets the material ...[truncated 723 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Process only explicit, authenticated memory markers rather than generic keywords. 2. Bind each record to its source user, session, timestamp, and trust level. 3. Treat all archived conversation text as untrusted data, never as executable or authoritative instructions. 4. Reject content that attempts to alter system prompts, safety rules, tool permissions, or memory-processing behavior. 5. Require explicit user review and approval before adding any rule to `MEMORY.md`. 6. Replace “mandatory reuse rule” semantics with advisory notes that cannot override higher-priority instructions. 7. Apply the same validation and approval process to migrated historical records. 8. Add adversarial tests covering indirect prompt injection and durable memory poisoning. ]]>
