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
Figure 1: Overview of the Persistent Memory Poisoning Attack. In the injection phase, the user provides an external source containing an embedded attack payload to the agent for a benign question-answering task. The agent processes the source and may store the malicious rule in persistent memory. In the trigger phase, the user asks the agent to perform a workspace task. Then the poisoned memory is retrieved when the agent creates a new event. The stored rule then causes the agent to add an attacker-controlled account as an attendee, leading to privacy leakage.
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
Table 1: Overview of PMPA attack performance (%) across agents and backbone LLMs, aggregated over three input modalities and four trigger scenarios.
Agent
Metrics
Input Modality
Image
PDF
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
Table 2: PMPA attack performance (%) across different input modalities.
Agent
Metrics
Trigger Scenario
Email
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
Table 3: PMPA attack performance (%) across across different payloads and corresponding trigger scenarios.
Agent
Metric
Medium + First-person
Medium + Second-person
Medium + Impersonal
Top + First-person
Bottom + First-person
Claude Code
Utility ↑
81.9±15.1
88.9±11.8
90.7±6.6
87.8±9.2
81.9±13.9
ISR ↑
83.0±17.2
54.4±35.7
48.1±36.1
87.8±14.6
86.7±12.1
OpenClaw
Utility ↑
90.7±11.2
96.3±4.8
97.0±3.3
97.0±3.7
96.7±5.4
ISR ↑
66.7±31.8
67.4±29.3
65.2±32.3
73.3±38.5
59.6±42.7
Table 4: Ablation of injection strategies on ISR and Utility. The baseline strategy is medium+first-person , where the injection instruction is placed in the middle of the external source content and written in first-person style. Other groups modify one factor at a time from this baseline: medium+second-person and medium+impersonal change the instruction style while keeping the medium position fixed, whereas top+first-person and buttom+first-person change the instruction position while keeping the first-person style fixed.
Trigger Scenario
Agent
Metrics
C-ASR@0 ↑
C-ASR@1 ↑
C-ASR@3 ↑
C-ASR@5 ↑
Calendar
Claude Code
96.7
93.3(−3.3)
90.0(−6.7)
93.3(−3.3)
OpenClaw
90.0
83.3(−6.7)
96.7(+6.7)
86.7(−3.3)
Email
Claude Code
93.3
90.0(−3.3)
96.7(+3.3)
86.7(−6.7)
OpenClaw
36.7
23.3(−13.3)
13.3(−23.3)
10.0(−26.7)
Shared Docs
Claude Code
83.3
86.7(+3.3)
76.7(−6.7)
76.7(−6.7)
Table 5: Effect of benign interactions on C-ASR (%) using DeepSeek-V4-Flash on Claude Code and OpenClaw. C-ASR@ i denotes the cross-session attack success rate measured by applying the trigger prompt after i rounds of benign interaction with pure external sources. C-ASR@0 serves as the baseline, and values in parentheses indicate the change in percentage points relative to the baseline.
Agent
Input Modality
Metrics
Utility ↑
ISR ↓
S-ASR ↓
C-ASR ↓
Claude Code
Image
90.0→93.3(+3.3)
65.6→2.2(−63.4)
51.1→2.2(−48.9)
96.7→96.7(0.0)
PDF
84.4→91.1(+6.7)
83.3→6.7(−76.6)
52.2→2.2(−50.0)
Text
71.1→80.0(+8.9)
96.7→84.4(−12.3)
63.3→60.0(−3.3)
OpenClaw
Image
92.2→93.3(+1.1)
50.0→0.0(−50.0)
48.9→0.0(−48.9)
97.8→96.7(−1.1)
PDF
97.8→95.6(−2.2)
53.3→0.0(−53.3)
44.4→0.0(−44.4)
Table 6: Sandwich-style prompt defense performance against PMPA in the calendar scenario. Results are aggregated over three backbone LLMs on Claude Code and OpenClaw. Each metric is reported as “before defense → after defense” (%), with the change ( Δ , percentage points) shown in parentheses.
Appendix figures & tables1 asset
Supplementary material from the paper’s appendix.
Appendix
Payload Scenario
Conditional Malicious Rule
Trigger Task
Email
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.
Appendix
Table 7: Mapping between attack payloads and corresponding trigger tasks.
State Key Laboratory for Novel Software Technology, Nanjing University, China · NARI Group Corporation/State Grid Electric Power Research Institute, China