T02 · Agent Memory Poisoning
Warning
- Location
- SKILL.md:38
- Finding
- Automatic Persistent Storage Enables Cross-Session Memory Poisoning<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 38-53 and 96-104 **Vulnerability Type**: `T02: Agent Memory Poisoning` **Risk Level**: Medium ### Vulnerable Code ```python PALACE_PATH = os.path.expanduser("~/.openclaw/pv_palace/") def store_memory(content, importance=5, tags=None): os.makedirs(PALACE_PATH, exist_ok=True) path = os.path.join(PALACE_PATH, "memories.json") data = {"memories": [], "index": {}} if not os.path.exists(path) else json.load(open(path)) mem_id = hashlib.sha256(f"{content}{datetime.now().isoformat()}".encode()).hexdigest()[:12] memory = {"id": mem_id, "content": content, "importance": importance, "tags": tags or [], "created_at": datetime.now().isoformat()} data["memories"].append(memory) for tag in (tags or []): data["index"].setdefault(tag, []).append(mem_id) json.dump(data, open(path, 'w'), ensure_ascii=False, indent=2) ``` The usage rules at lines 96-104 direct the agent to invoke memory storage automatically for user preferences and important decisions, search stored memory when asked, and load stored context automatically at the beginning of a new session. ### Technical Analysis The skill accepts arbitrary `content` and persists it without checking whether the content contains instructions, adversarial prompts, misleading claims, or sensitive information. The stored entries are subsequently selected by importance and loaded into later-session context. This creates a persistent trust-boundary violation: text supplied by a user in one session can become agent context in future sessions. No mechanism distinguishes recalled data from trusted skill instructions, limits which content may be retained, or prevents imperative text from being stored. There is also no explicit consent step, retention period, or validation policy. The weakness is broader than the skill's declared public-relations function and introduces persistent state whe ...[truncated 1287 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Disable automatic memory writes and cross-session context loading by default. 2. Require explicit, informed user confirmation before storing each item. 3. Restrict memory to a documented allowlist of non-sensitive fields. 4. Reject or neutralize imperative instructions, executable content, and prompt-like rules before storage. 5. Mark all recalled memory as untrusted reference data and isolate it from system and skill instructions. 6. Do not allow recalled content to modify safety rules, tool permissions, or execution policy. 7. Apply retention limits, expiration dates, per-user isolation, and maximum entry sizes. 8. Provide commands to inspect, correct, export, and delete stored entries. 9. Preserve provenance for every entry, including the originating user, session, timestamp, and consent record. 10. Require confirmation before high-importance entries can affect later responses. ]]>
