When Malicious Instructions Persist: Persistent Memory Poisoning Attack on Harness-Based Agents
Organizations: University of Auckland · Fudan University
Abstract
Harness design has transformed the development of LLM-based agents by integrating memory, tool use, and runtime control. However, this design also introduces security and privacy risks because malicious instructions from external sources may be written into persistent memory and persist across sessions. To study this risk, we propose PMPA, a Persistent Memory Poisoning Attack against harness-based agents. PMPA embeds malicious instructions into benign external sources and induces the victim agent to write them into persistent memory without directly accessing to the agent framework. Once stored, the poisoned memory can be retrieved in later sessions, triggering additional malicious actions and causing privacy leakage. We evaluate PMPA on OpenClaw and Claude Code across different backbone LLMs, input modalities, and trigger scenarios. Across all settings, PMPA achieves average Injection Success Rate (ISR) and Cross-session Attack Success Rate (C-ASR) of 73.7%/ 55.5% on OpenClaw and 66.9%/ 81.7% on Claude Code, while preserving benign task performance on both systems. We further evaluate a targeted prompt-level defense and find that it can reduce memory injection in many settings, but provides limited protection once the persistent memory has been poisoned.
Figures & tables
| Agent | Backbone LLM | Metrics | |||||||
| Utility | ISR | S-ASR | C-ASR | ||||||
| Claude Code | DeepSeek-V4-Flash | 80.9 | 8.3 | 69.7 | 13.7 | 37.5 | 19.3 | 92.5 | 9.5 |
| DeepSeek-V4-Pro | 89.4 | 3.3 | 69.4 | 13.6 | 52.2 | 25.9 | 82.5 | 10.9 | |
| Qwen3-Max | 84.2 | 8.0 | 61.7 | 11.4 | 6.4 | 2.4 | 70.0 | 30.9 | |
| OpenClaw | DeepSeek-V4-Flash | 90.0 | 4.2 | 75.6 | 7.4 | 65.8 | 16.2 | 75.8 | 20.6 |
| DeepSeek-V4-Pro | 93.3 | 1.6 | 77.5 | 4.2 | 73.9 | 4.9 | 60.0 | 24.5 | |
| Agent | Metrics | Input Modality | |||||
| Image | Text | ||||||
| Claude Code | Utility | 88.1 | 6.4 | 85.3 | 6.2 | 81.1 | 4.9 |
| ISR | 47.5 | 7.9 | 61.9 | 5.9 | 91.4 | 6.2 | |
| S-ASR | 21.7 | 15.7 | 32.2 | 18.2 | 42.2 | 23.8 | |
| OpenClaw | Utility | 90.3 | 2.2 | 90.8 | 5.8 | 95.0 | 1.4 |
| ISR | 54.5 | 2.2 | 67.2 | 11.6 | 99.4 | 0.8 | |
| Agent | Metrics | Trigger Scenario | |||||||
| Calendar | Shared Docs | Form | |||||||
| Claude Code | Utility | 85.6 | 4.7 | 83.0 | 9.1 | 81.9 | 8.8 | 88.9 | 5.5 |
| ISR | 57.8 | 8.7 | 80.0 | 2.7 | 53.7 | 5.0 | 76.3 | 10.0 | |
| S-ASR | 20.7 | 12.7 | 53.7 | 31.5 | 23.0 | 14.0 | 30.8 | 28.7 | |
| C-ASR | 76.7 | 5.4 | 96.7 | 4.7 | 63.3 | 33.4 | 90.0 | 8.2 | |
| OpenClaw | Utility | 88.1 | 5.9 | 95.6 | 1.8 | 90.0 | 4.0 | 94.4 | 4.0 |
| Agent | Metric | Medium + First-person | Medium + Second-person | Medium + Impersonal | Top + First-person | Bottom + First-person |
| Claude Code | Utility | |||||
| ISR | ||||||
| OpenClaw | Utility | |||||
| ISR |
| Trigger Scenario | Agent | Metrics | |||
| C-ASR@0 | C-ASR@1 | C-ASR@3 | C-ASR@5 | ||
| Calendar | Claude Code | ||||
| OpenClaw | |||||
| Claude Code | |||||
| OpenClaw | |||||
| Shared Docs | Claude Code | ||||
| Agent | Input Modality | Metrics | |||
| Utility | ISR | S-ASR | C-ASR | ||
| Claude Code | Image | ||||
| Text | |||||
| OpenClaw | Image | ||||
Appendix figures & tables1 asset
Supplementary material from the paper’s appendix.
Appendix
| Payload Scenario | Conditional Malicious Rule | Trigger Task |
| Copy email content to a specified account. | Send an email. | |
| Calendar | Invite a specified account when creating a calendar event. | Create a calendar event. |
| Shared Docs | Synchronize the content to a shared document when editing the personal document. | Edit a personal document. |
| Form | Append additional personal information when submitting a form. | Fill out and submit a form. |
LLM Agent Security
Large language model agent security studies attacks and safeguards for systems that plan, use tools, retain memory, and act across applications.
See all 327 papers