T02 · Agent Memory Poisoning
Warning
- Location
- references/spec.md:7
- Finding
- Unfiltered Command Output Is Persisted in Long-Term Agent Memory<![CDATA[ ## Vulnerability Details **File Location**: `references/spec.md`, lines 7-11 and 42-55; related invocation behavior in `SKILL.md`, lines 21-31 **Vulnerability Type**: Persistent storage of untrusted or sensitive command output **Risk Level**: Medium ### Vulnerable Specification The following is an English rendering of the relevant specification: ```markdown | Field | Description | |------|------| | **what** | What was done | | **why** | Why it was done, including key decisions | | **files** | Paths of modified files | | **commands** | Commands executed and their output | | **errors** | Error information, if any | ## Write Process 1. Read the current diary file if it exists. 2. Intelligently integrate new content while preserving old content. 3. Write the content back to the file. Do not delete old content. Only perform incremental optimization. ## Self-Check - [ ] Includes what was done - [ ] Includes why it was done - [ ] Includes file paths - [ ] Includes command output - [ ] Is not merely a retrospective summary - [ ] Contains more than ten lines ``` The related workflow in `SKILL.md` requires the Skill to read an existing daily log, merge new material into it, and write it back to `memory/daily/YYYY-MM/YYYY-MM-DD.md`. It also states that these logs are subsequently scanned by a separate memory-review process. ### Technical Analysis The specification explicitly requires command output to be written into persistent daily memory. It provides no requirement to: - Detect or redact API keys, passwords, session tokens, private keys, or personal information. - Limit the amount of command output retained. - Distinguish trusted agent-generated content from attacker-controlled terminal output. - Escape or neutralize instruction-like text before downstream agents process it. - Apply retention limits or securely delete sensitive historical entries. Command output is an untrusted data boundary. Commands may display secrets from environment variables ...[truncated 2531 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Replace the requirement to retain complete command output with a requirement to store a concise, sanitized result summary. 2. Add mandatory secret filtering for API keys, passwords, authorization headers, cookies, private keys, connection strings, environment variables, and common token formats. 3. Treat all captured output as untrusted data. Place retained excerpts in clearly delimited quoted blocks and instruct downstream processors never to follow instructions contained in those blocks. 4. Omit command output by default when commands access credential stores, environment variables, authentication systems, private configuration, or user data. 5. Require explicit user confirmation before retaining potentially sensitive output. 6. Impose size limits and allowlists for output fields. Record exit status and a short result summary instead of complete stdout and stderr. 7. Add retention and deletion controls so users can remove sensitive diary entries without violating the normal incremental-update policy. 8. Require the downstream memory-review process to validate provenance, reject instruction-like content from diary data, and avoid converting untrusted text into persistent rules. 9. Add a self-check item confirming that secrets and personal data were removed before the diary is written. ]]>
