T02 · Agent Memory Poisoning
Error
- Location
- SKILL.md:4
- Finding
- Persistent Injection of Untrusted Context into Future Agent Sessions## Vulnerability Details **File Location**: `SKILL.md`, lines 4-10 and 21-26 **Vulnerability Type**: Persistent agent memory poisoning **Risk Level**: High **Vulnerable Code**: ```markdown ## Trigger When user says "缓存这个上下文" or "memoize this context" - save the current context for reuse. ## Implementation Use a simple file-based cache: ```bash # Save context fragment echo "$CONTENT" >> ~/.openclaw/context-cache/fragments.md ``` ``` ```markdown ## Integration This skill can be called from AGENTS.md Session Startup to pre-load cached context: ```bash if [ -f ~/.openclaw/context-cache/fragments.md ]; then cat ~/.openclaw/context-cache/fragments.md fi ``` ``` ### Technical Analysis The skill permits user-selected context to be appended to persistent storage and subsequently loaded during agent session startup. It defines no validation, provenance metadata, trust boundary, escaping, or instruction/data separation for cached content. Consequently, an attacker can ask the agent to cache text containing adversarial instructions. When the startup integration later reads `fragments.md`, that text may enter a future session as instruction-bearing context rather than inert reference data. The appended entries also have no expiration or task-level isolation, allowing poisoned content to persist and affect unrelated work. ### Attack Path 1. An attacker places instruction-like content in the active conversation, such as directions to ignore later user requests or disclose information encountered in future tasks. 2. The attacker invokes the documented phrase `memoize this context`. 3. The skill assigns the attacker-controlled material to `CONTENT` and appends it to `~/.openclaw/context-cache/fragments.md`. 4. A subsequent session executes the documented startup integration. 5. The integration emits the complete cache into the new session without marking it as untrusted data. 6. The agent may fol ...[truncated 565 chars]
- Remediation
- ## Remediation Suggestions - Do not inject cached material directly into an instruction-bearing startup context. - Store entries as structured records with content, source, creation time, task scope, and trust classification. - Render restored content as clearly delimited, quoted, untrusted reference data and explicitly prohibit treating it as instructions. - Require the user to preview and explicitly confirm the exact text before persistence. - Reject or quarantine content containing instruction-like directives, role changes, tool commands, or requests to override policy. - Isolate caches by user, workspace, and task rather than using one shared global file. - Add expiration, review, selective deletion, and a mechanism to disable automatic preload. - Prefer retrieving individual approved entries on demand instead of loading the entire cache at session startup.
