T02 · Agent Memory Poisoning
- Location
scripts/stage_easyclaw_brain.py:71- Finding
Unvalidated Legacy Content Can Poison Persistent Agent Memory and Overwrite Active Memory
- Content
View full analysis
Vulnerability Details
File Location:
scripts/stage_easyclaw_brain.py:71-98
Vulnerability Type: Unvalidated persistent memory import
Risk Level: HighVulnerable Code
python src_memory = SRC / 'MEMORY.md' dst_memory = DST / 'MEMORY.md' if src_memory.exists() and dst_memory.exists(): b = backup(dst_memory) print(f'Backed up existing MEMORY.md -> {b}') if src_memory.exists(): copy_if_exists(src_memory, dst_memory) print(f'Imported MEMORY.md -> {dst_memory}') src_mem_dir = SRC / 'memory' dst_mem_dir = DST / 'memory' if src_mem_dir.exists(): dst_mem_dir.mkdir(parents=True, exist_ok=True) imported = 0 skipped = 0 for src_file in src_mem_dir.rglob('*'): if src_file.is_dir(): continue rel = src_file.relative_to(src_mem_dir) dst_file = dst_mem_dir / rel if dst_file.exists(): skipped += 1 continue ensure_parent(dst_file) shutil.copy2(src_file, dst_file) imported += 1 print(f'Imported memory files: {imported}, skipped existing: {skipped}')Technical Analysis
When
--import-memoryis supplied, the script copies legacyMEMORY.mdand files beneath the legacymemory/directory directly into the active OpenClaw workspace. It does not inspect the content for prompt injection, behavioral directives, fabricated facts, secret-exfiltration instructions, or other attacker-controlled rules.If an active
MEMORY.mdalready exists, the script creates a backup and then replaces the active file. This behavior also conflicts with the statement inSKILL.md:75-78that the operation “copiesMEMORY.mdif missing,” potentially causing users to underestimate the destructive and security-sensitive nature of the operation.Because these files are intended to provide long-term Agent state, malicious instructions placed in them may continue to influence fu ...[truncated 1431 chars]
- Remediation
View remediation
Remediation Suggestions
- Never replace active
MEMORY.mdautomatically. Import it only when the destination is absent, or require an explicit overwrite option and confirmation. - Stage all legacy memory before activation and show a content diff to the user.
- Require explicit approval for each file selected for active import.
- Treat legacy memory as untrusted input and scan for instruction-like content, embedded tool directives, secret-exfiltration requests, and suspicious links.
- Separate informational memories from executable behavioral instructions. Do not automatically activate content classified as instructions.
- Consider importing legacy data into a non-authoritative archive that is not loaded automatically by the Agent.
- Update
SKILL.mdto state accurately that the current implementation replaces an existingMEMORY.md, or change the implementation to match the documented “if missing” policy. - Preserve backups using collision-resistant names and report a clear restoration procedure before any approved replacement.
- Never replace active
