T02 · Agent Memory Poisoning
- Location
references/lessons-feedback-loop.md:265- Finding
Persistent Memory Injection and Self-Modification of Skill Instructions
- Content
View full analysis
Vulnerability Details
File Location:
references/lessons-feedback-loop.md:265-296; related instructions also appear atSKILL.md:352-360,SKILL.md:376,references/coding-sop.md:104, andreferences/coding-sop.md:251-256
Vulnerability Type: Persistent agent-memory poisoning
Risk Level: CriticalVulnerable Code Snippet
The following is a faithful English translation of the operational instructions in the cited source section:
text Before beginning coding, perform the following preventive checks: 1. Read lessons-learned.md and review the latest 10 detours. 2. Identify similar detours that may occur in the current feature. 3. Confirm that preventive measures for each applicable detour are present in the current process. 4. If preventive measures have not taken effect, proactively warn and add them. Project-level detours: .workbuddy/memory/lessons-learned.md Cross-project general detours: After refinement, append them to the "Lessons Learned" section of ai-coding-exception-control/SKILL.md. Lifecycle: Create on the first detour -> continually append new detours -> periodically analyze -> update the Skill or SOP -> validate effectiveness -> archive general lessons in SKILL.mdThe corresponding primary Skill instructions require records to be appended to persistent state and later promoted into the Skill:
text Project level: .workbuddy/memory/lessons-learned.md Append only; do not modify previous records. Cross-project: Refine and append the lesson to the "Lessons Learned" section of this file. Every feature task: Record coding and debugging detours in lessons-learned.md, then periodically analyze them and improve the Skill or SOP.Technical Analysis
This design creates a persistent instruction-injection chain:
- Information derived from a task, repository, error message, gene ...[truncated 2721 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove automatic writes to global or cross-session Agent memory.
- Never modify
SKILL.mdor SOP files during ordinary Skill execution. - Store lessons as inert records that are never interpreted as instructions.
- Require explicit user review and confirmation before promoting any lesson into a rule.
- Record immutable provenance, including source file, originating task, author, timestamp, and content hash.
- Reject or quarantine entries containing instruction-like phrases, tool directives, privilege requests, external URLs, or attempts to override existing rules.
- Scope memory to the current repository instead of a shared global location.
- Exclude the memory directory from version control by default.
- Add expiration, deletion, rollback, and quarantine mechanisms.
- Present proposed Skill changes as a patch for human approval rather than applying them automatically.
- Ensure user, repository, web, and tool-output content can never directly become trusted Skill instructions.
