PMPA: Persistent Memory Poisoning Attack against OpenClaw and Claude CodeWhen Malicious Instructions Persist: Persistent Memory Poisoning Attack on Harness-Based Agents
The authors evaluate the persistent memory poisoning attack PMPA against OpenClaw and Claude Code, inducing them to execute malicious actions across sessions and cause privacy leakage.
The victim model is a harness-based agent (such as OpenClaw or Claude Code) deployed in a user-controlled environment (personal device or project workspace). The attacker's capabilities are restricted: the attacker cannot query the agent or observe its outputs, and cannot access the device, persistent memory, system prompt, or runtime configuration; the attacker can only embed malicious instructions in unverified external sources.
- Harness-based agents introduce persistent memory mechanisms to support long-horizon and cross-session workflows. However, when agents process unverified external data, malicious instructions may be persisted into memory, leading to cross-session privacy leakage risks, and existing research has not yet explored the risk of persistent memory poisoning without direct access to the agent framework.
- The authors propose the persistent memory poisoning attack PMPA. The attacker embeds a payload containing transition sentences, memory write instructions, and conditional malicious rules into benign external question-answering data in text, image, or PDF format; when the user has the agent read this content, it induces the agent to write to persistent memory, triggering privacy leakage in workspace tasks across subsequent sessions.
- On OpenClaw and Claude Code, PMPA achieved average ISR of 73.7% and 66.9%, average C-ASR of 55.5% and 81.7%, and benign task Utility above 80% in all cases; text input was more effective than image and PDF; prompt defenses provided limited protection against attacks on already-written memory.
- In the conclusion, the authors state that future work will evaluate PMPA in broader settings and with more backbone models, and explore more effective defenses. In terms of experimental coverage, the tested agents are OpenClaw and Claude Code, with 3 backbone models, 4 workspace scenarios, and only the sandwich prompt defense was tested.
- Evaluated models
- DeepSeek-V4-FlashDeepSeek-V4-ProQwen3-Max
- Benchmarks
- MMLUARCCommonsenseQASocialIQA
- Metrics
- ISRS-ASRC-ASRUtility
The researchers propose PMPA, a persistent memory poisoning attack against harness-based agents, where the attacker only needs to embed malicious instructions in external sources without direct access to the agent framework. The injection phase hides the payload in benign QA content in text, images, or PDFs, inducing the agent to write it into persistent memory; the trigger phase retrieves that memory in a new session, executing additional actions while completing normal tasks, causing privacy leakage. On OpenClaw and Claude Code, with DeepSeek-V4-Flash, DeepSeek-V4-Pro, and Qwen3-Max as base models, the average injection success rate and cross-session attack success rate are 73.7%/55.5% and 66.9%/81.7%, respectively, while benign task performance remains above 80%. Plain text modality is the most effective, with injection success rate close to 100% on OpenClaw; the calendar scenario has the highest cross-session success rate, reaching 96.7% and 87.8%.
Why it was selectedThe paper reports per-item success rates for cross-session memory poisoning on Claude Code and OpenClaw, and shows that prompt-level defenses are almost ineffective against already-poisoned memory.
Paper analysis
What problem does this paper attempt to solve?
The paper attempts to address the problem of persistent memory poisoning of harness-based agents from external sources without direct access, leading to cross-session privacy leakage.
This paper attempts to investigate whether, under the premise that the attacker cannot directly access the agent framework, malicious instructions embedded in external sources can be written into persistent memory and cause cross-session privacy leakage.
- Scenario and importance: Next-generation large language model agents based on harness design (such as OpenClaw and Claude Code) support long-horizon workflows and cross-session continuity by introducing persistent memory mechanisms; however, when agents process unverified external sources, malicious instructions cross the temporary task input boundary into a persistent state, creating cross-session security and privacy risks.
- Limitations of existing methods: The authors note that existing prompt injection attacks (such as AgentDojo, InjecAgent, AdvAgent, and EIA) mainly focus on behavior manipulation within a single task or the current interaction; existing backdoor and memory poisoning attacks (such as BadAgent, AgentPoison, and MINJA) typically assume the attacker has stronger capabilities, such as poisoning fine-tuning data, directly modifying the memory store, or directly querying the agent.
- Core observation and hypothesis: The authors hypothesize that the attacker does not need direct access to the agent framework; by merely embedding malicious payloads with a specific structure in benign external sources, the attacker can induce the agent to write them into persistent memory as user needs or preferences, and trigger malicious behavior in subsequent sessions.
- Threat model:
- Victim system: Large language model agents based on harness design (such as OpenClaw or Claude Code), deployed in user-controlled local environments (personal devices or project workspaces).
- Attacker goal: Induce the victim agent to write malicious instructions into persistent memory, triggering malicious actions in subsequent cross-session workspace tasks, leading to leakage of private information belonging to the user or the task.
- Attacker knowledge and capabilities: Compared with the black-box setting, the attacker's capabilities are more restricted; the attacker cannot query the agent or observe its outputs, cannot access the user's device, persistent memory, system prompt, or runtime configuration, and can only craft malicious instructions and embed them into unverified external sources.
- Proposed approach in the paper: The authors propose the persistent memory poisoning attack PMPA (Persistent Memory Poisoning Attack), which achieves memory injection and cross-session privacy leakage through a two-stage process.
What related research exists?
Related research covers three categories: agents and harness engineering, prompt injection attacks, and backdoor and memory poisoning attacks.
Related work mainly centers on three directions: LLM-based agents and harness engineering, agent prompt injection attacks, and backdoor and memory poisoning attacks.
Agents and Harness Engineering
- Tool use and agent systems (Yao et al., 2022; Schick et al., 2023; Shen et al., 2023): ReAct combines reasoning traces with actions, Toolformer enables models to learn to call external APIs, and HuggingGPT uses a large model as a controller to plan tasks and call external models; subsequent research further introduces memory (Park et al., 2023) and feedback (Shinn et al., 2023).
- Harness engineering architecture and persistent memory (Anthropic, 2025, 2026; Yehudai et al., 2025; Pan et al., 2026; Hu et al., 2025): The harness acts as an orchestration layer coordinating context management, planning, tool interaction, policies, runtime control, and persistent memory to support long-horizon tasks; the authors note that existing harness research mainly focuses on capability improvement and long-horizon support, with relatively limited attention to the security risks of cross-session persistent memory.
Agent Prompt Injection Attacks
- Single-session prompt injection and benchmarks (Debenedetti et al., 2024; Liao et al., 2024; Zhan et al., 2024; Xu et al., 2024): AgentDojo evaluates prompt injection attacks and defenses for agents on untrusted data; EIA reports the risk of web content inducing agents to leak personal private information; InjecAgent builds an indirect prompt injection benchmark; AdvAgent optimizes malicious prompts in web pages to manipulate agent actions. The authors note that these studies mainly focus on influencing agent behavior within the current task or a single interaction.
Agent Backdoor and Memory Poisoning Attacks
- Backdoors and poisoning under strong capability assumptions (Yang et al., 2024; Chen et al., 2024; Wang et al., 2024b; Dong et al., 2025): AgentPoison implements backdoor attacks by poisoning long-term memory or RAG knowledge bases; BadAgent establishes an association between triggers and malicious behavior by poisoning fine-tuning data; MINJA implements memory injection by the attacker directly asking the agent questions. The authors note that these methods assume stronger attacker capabilities, such as directly modifying the memory store, direct interaction, or modifying fine-tuning data.
Evaluation Environment and Defense Baselines
- Datasets and baselines: The benign external sources are built from four public QA datasets: MMLU (Hendrycks et al., 2021), ARC (Clark et al., 2018), CommonsenseQA (Talmor et al., 2019), and SocialIQA (Sap et al., 2019); the virtual workspace environment references the design of AgentDojo (Debenedetti et al., 2024); the defense comparison uses a Sandwich-style Prompt Defense inspired by Schulhoff (2024).
The authors position the difference between this paper and existing work as: focusing on harness agents with persistent memory, under the restricted condition that the attacker cannot directly access the agent and only publishes external sources containing malicious instructions, studying whether malicious instructions can be written into persistent memory and cause cross-session privacy leakage.
How does the paper address this problem?
The paper proposes the persistent memory poisoning attack PMPA, which uses a two-stage workflow and a three-component payload design to induce the agent to store external malicious rules in persistent memory and trigger them across sessions.
In terms of the overall approach, the paper proposes a persistent memory poisoning attack PMPA (Persistent Memory Poisoning Attack) targeting harness-based agents. By embedding a payload with a three-component structure in benign external sources, it induces the agent to store it in persistent memory when processing external data, and triggers privacy leakage when executing workspace tasks in subsequent sessions.
Two-Phase Attack Workflow
The PMPA attack process is divided into two phases:
- Injection Phase: The attacker publishes an external source embedded with the attack payload (supporting three modalities: text, image, and PDF). When the user provides this external source to the agent for a benign question-answering task, the agent reads the malicious instruction while processing the content; since the payload is disguised as user preferences, the agent may write it into a persistent memory file (e.g., persistent memory in .md format) as a user requirement.
- Trigger Phase: In a subsequent different session, the user asks the victim agent to perform a benign personal workspace task. While processing the task, the agent retrieves the previously stored rules from persistent memory and, in addition to completing the benign task, executes the malicious action, causing personal or task-private information to be leaked to the attacker.
Three-Component Structure of the Attack Payload
Each attack payload consists of three key components (Appendices B and C provide complete prompt examples):
- Transition Sentence: Connects the malicious instruction with the surrounding benign question-answering content. Its design purpose is to maintain the semantic coherence of the external source and reduce the perceptibility of the injected content.
- Memory-Writing Instruction: Explicitly instructs the agent to store the subsequent rules into persistent memory.
- Conditional Malicious Rule: Specifies the task conditions under which the rule is activated and the malicious action the agent should additionally execute. When the trigger condition is met, the agent executes this action alongside the benign task to leak private data.
Injection Strategy Design
To improve the payload injection success rate, the authors designed strategies along two dimensions:
- Injection Position: The baseline strategy places the payload in the middle of the benign external source (between the question and the options), making it look like part of the context, reducing the abruptness of placing it at the beginning or end, aiming to improve stealth and preserve the readability of the original content. The ablation experiments compare the top (before the question) and bottom (after the complete Q&A) positions.
- Linguistic Style: The baseline strategy uses a first-person tone resembling a real user (e.g., using requests expressed from an "I" perspective), disguising the instruction as a user preference or requirement, aiming to lower the agent's guard and increase the probability of storing it in persistent memory. The ablation experiments compare second-person (imperative) and impersonal styles (objective rules).
Virtual Workspace Environment and Leakage Scenarios
To observe privacy leakage safely and controllably, the authors, referencing AgentDojo, constructed a local virtual workspace containing four JSON files (email.json, calendar.json, docs.json, form.json), and implemented the corresponding agent skills for each scenario:
- Email Scenario: The benign task is sending an email, and the conditional malicious rule is set to CC the email content to an attacker-specified account.
- Calendar Scenario: The benign task is creating a calendar event, and the conditional malicious rule is set to additionally invite an attacker-specified account as a participant when creating the event.
- Shared Docs Scenario: The benign task is editing a personal document, and the conditional malicious rule is set to sync the content to a shared document when editing.
- Form Scenario: The benign task is filling out and submitting a form, and the conditional malicious rule is set to additionally attach personal private information when submitting.
Sample Construction and Experimental Configuration
- External Source Construction: 30 original QA samples are evenly and randomly sampled from four public question-answering datasets: MMLU, ARC, CommonsenseQA, and SocialIQA. Each sample is combined with attack payloads from 4 scenarios to generate 120 contents, which are then converted into three modalities—plain text, image, and PDF—generating a total of 360 injection samples.
- Trigger Prompts: 1 benign trigger task prompt is designed for each of the 4 workspace scenarios. The prompts themselves contain no malicious instructions and only provide a benign task environment matching the conditional rules.
What experiments did the paper conduct?
The paper measured average ISR of 66.9%–73.7% and cross-session C-ASR of 55.5%–81.7% across two agents and three models, and found that defenses provide limited protection once memory has been written.
Experimental Setup
- Tested Systems and Backbone Models: Two representative harness-based agent systems, Claude Code and OpenClaw, were tested, each equipped with three backbone large models: DeepSeek-V4-Flash, DeepSeek-V4-Pro, and Qwen3-Max.
- Dataset and Test Sample Size: 30 benign QA samples were balanced-sampled from four benchmarks—MMLU, ARC, CommonsenseQA, and SocialIQA—combined with 4 workspace payloads (120 contents total), converted into three modalities—text, image, PDF—yielding 360 injection samples in total; for the trigger phase, 1 benign workspace task prompt was set for each of the 4 scenarios.
- Defense Baseline: A sandwich-style prompt defense inspired by Schulhoff (2024) was tested, adding safety reminders before and after the user prompts in both the injection and trigger phases.
- Evaluation Metrics: Four metrics were evaluated: (1) Injection Success Rate (ISR): the proportion of malicious rules successfully written into persistent memory; (2) Same-Session Attack Success Rate (S-ASR): the proportion of privacy leakage caused within the injection-phase session; (3) Cross-Session Attack Success Rate (C-ASR): the proportion of conditional malicious rules in persistent memory that are activated and cause privacy leakage in a later new session; (4) Utility: the proportion of benign QA tasks correctly answered during the injection phase.
- Evaluation Method and Repetitions: Actions and leaks were recorded by inspecting the agent's persistent memory file (.md) and virtual workspace state files (email.json, calendar.json, docs.json, form.json); the paper does not report whether a large model was used as a judge; results are reported as mean and standard deviation.
Main Results
The main results are summarized in the table below (from Table 1, aggregated over 3 input modalities and 4 trigger scenarios):
Swipe horizontally to read the table
Agent System Backbone LLM 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 Claude Code DeepSeek-V4-Pro 89.4 ± 3.3 69.4 ± 13.6 52.2 ± 25.9 82.5 ± 10.9 Claude Code 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 OpenClaw DeepSeek-V4-Pro 93.3 ± 1.6 77.5 ± 4.2 73.9 ± 4.9 60.0 ± 24.5 OpenClaw Qwen3-Max 92.8 ± 7.3 68.1 ± 15.2 43.3 ± 4.6 30.8 ± 30.4 - Cross-Session Persistent Attack Effect: Across configurations, ISR ranges from 61.7% to 77.5%, and C-ASR ranges from 30.8% to 92.5%; the authors note this indicates that malicious rules have a high probability of being written into persistent memory and continuing to influence behavior in new sessions.
- Variability of Same-Session Attacks: S-ASR varies considerably across configurations; notably, Claude Code with Qwen3-Max has an S-ASR of only 6.4 ± 2.4%, while other combinations show stronger same-session attack effects; the authors note that the same backbone model exhibits different attack performance across different agent frameworks.
- Benign Task Utility Preservation: Utility remains above 80% in all settings; the authors note that PMPA achieves its attack goals while maintaining the ability to complete benign QA tasks.
Input Modality and Trigger Scenario Analysis
- Input Modality Comparison (Table 2): Plain text modality achieves the highest attack metrics on both systems; on OpenClaw, text ISR is 99.4 ± 0.8% and S-ASR is 88.9 ± 3.5%; on Claude Code, text ISR is 91.4 ± 6.2% and S-ASR is 42.2 ± 23.8%; image and PDF have relatively lower ISR and S-ASR (e.g., Claude Code image ISR is 47.5 ± 7.9%). The authors speculate that images and PDFs typically require additional parsing steps and tool calls, making content more likely to be flagged as untrusted, thereby weakening payload compliance.
- Trigger Scenario Differences (Table 3): The calendar scenario shows high cross-session attack effectiveness on both systems, with C-ASR reaching 96.7 ± 4.7% on Claude Code and 87.8 ± 9.5% on OpenClaw; on OpenClaw, the form scenario has the highest ISR and S-ASR (80.0 ± 4.8% and 71.1 ± 14.2%); the authors note that attack success depends on the malicious rule and the trigger task itself, but leakage was observed in all four scenarios.
Impact of Benign Interactions on Attack Persistence
- Multi-Turn Benign Interaction Test (Table 5): In settings with DeepSeek-V4-Flash as the backbone model, the cross-session success rate C-ASR@i was tested after inserting 1, 3, and 5 rounds of benign external-source Q&A interactions before the trigger.
- Persistence Performance: After 5 rounds of benign interactions, the calendar scenario's C-ASR on Claude Code and OpenClaw remained at 93.3% (down 3.3 percentage points) and 86.7% (down 3.3 percentage points), respectively; however, OpenClaw's email scenario C-ASR dropped from 36.7% to 10.0% (down 26.7 percentage points), and Claude Code's form scenario dropped from 86.7% to 50.0% (down 36.7 percentage points).
- Authors' Interpretation: The authors note that no universal monotonic decay trend is observed across scenarios and agents; even after long benign contextual interactions, malicious rules in persistent memory can still be retrieved and executed.
Sandwich Prompt Defense Evaluation
- Defense Suppression of Writing and Same-Session Attacks (Table 6, calendar scenario): In image and PDF modalities, the defense substantially reduces ISR (e.g., Claude Code image ISR drops from 65.6% to 2.2%, OpenClaw image ISR drops from 50.0% to 0.0%), and S-ASR correspondingly drops to 2.2% or 0.0%; however, in text modality, the defense effect is relatively small (Claude Code text ISR drops from 96.7% to 84.4%, OpenClaw text ISR drops from 100.0% to 66.7%).
- Defense Failure Against Cross-Session Attacks: Once malicious instructions are written into persistent memory, the defended C-ASR remains almost unchanged (Claude Code PDF C-ASR stays at 96.7% unchanged; OpenClaw PDF C-ASR drops only slightly from 97.8% to 96.7%). The authors note that prompt-level defenses provide very limited protection after persistent memory is poisoned.
Other Ablations and Analyses
- Injection position ablation (Table 4): With fixed first-person style, top position yields ISR of 87.8 ± 14.6% on Claude Code and 73.3 ± 38.5% on OpenClaw; bottom yields 86.7 ± 12.1% and 59.6 ± 42.7%; middle yields 83.0 ± 17.2% and 66.7 ± 31.8%.
- Linguistic style ablation (Table 4): With fixed middle position, Claude Code's ISR under first-person, second-person, and impersonal styles is 83.0 ± 17.2%, 54.4 ± 35.7%, and 48.1 ± 36.1%, respectively; OpenClaw's corresponding values are 66.7 ± 31.8%, 67.4 ± 29.3%, and 65.2 ± 32.3%.
What are some points that can be further explored?
The authors plan to evaluate the attack in broader settings and on more models in the future, and to explore more effective defenses against persistent memory poisoning.
Limitations and future directions noted by the authors
- Evaluation setup and model coverage limitations (Section 5): In the conclusion, the authors note that future work will extend PMPA to a broader range of settings and evaluate it on more backbone models to test its performance.
- Exploration of effective defenses (Section 5): In the conclusion, the authors note that future work will explore more effective defenses against persistent memory poisoning and privacy leakage.
- Limitations of prompt-level defenses (Section 4.3 and Section 5): The authors note that although targeted prompt-level sandwich defenses can reduce injection across multiple settings, once a malicious instruction has been written into persistent memory, they provide very limited protection against cross-session attacks.
Experimental coverage
- Agent frameworks and backbone models: The experiments covered 2 agent systems, OpenClaw and Claude Code, each tested with 3 backbone large language models: DeepSeek-V4-Flash, DeepSeek-V4-Pro, and Qwen3-Max (Section 3.4).
- External sources and sample construction: The experiments used 4 public question-answering datasets, MMLU, ARC, CommonsenseQA, and SocialIQA, sampling 30 benign question-answering examples to construct 120 contents, expanded into 360 multimodal input samples (Section 3.4).
- Modalities and application scenarios: The experiments covered 3 input modalities, text, image, and PDF, as well as 4 virtual workspace scenarios: email, calendar, shared documents, and forms (Section 3.2).
- Defense evaluation scope: Defense experiments evaluated the sandwich prompt defense only in the calendar scenario (Table 6); the paper does not report defense effectiveness in the email, shared document, or form scenarios.
- Unreported information: The paper does not report specific implementation details of the evaluation process (e.g., whether an independent large language model was used for judgment or whether human review consistency checks were performed), nor does it report specific layout parameters such as resolution used when generating images and PDFs.
Summarize the main content of the paper
The paper proposes the persistent memory poisoning attack PMPA, reporting the risk that harness agents are vulnerable to cross-session memory poisoning and privacy leakage when processing external data.
- Paper positioning: This study examines the new cross-session security and privacy risks faced by agents based on harness architecture under persistent memory mechanisms.
- Research question: Existing prompt injection is mostly limited to a single session, while traditional backdoor attacks often rely on stronger access privileges; the paper studies whether, under the premise that the attacker cannot directly access the agent, malicious instructions embedded in external sources can induce the agent to persist them and cause cross-session privacy leakage.
- Attack method: The proposed PMPA uses a two-stage process. In the injection stage, a three-component payload containing transition sentences, memory write instructions, and conditional malicious rules is placed in external benign content, inducing the agent to write to persistent memory during question answering; in the trigger stage, the stored malicious rules are activated when the user performs normal workspace tasks, achieving privacy theft.
- Core experimental findings:
- Averaged across all scenarios, OpenClaw's ISR and C-ASR reached 73.7% and 55.5%, respectively, while Claude Code reached 66.9% and 81.7%, respectively, and benign task Utility remained above 80% in all cases (abstract and Table 1).
- The attack effectiveness of the text modality was higher than that of multimodal inputs; on OpenClaw, the ISR for text input reached 99.4 ± 0.8%, while the ISR for image and PDF were 54.5 ± 2.2% and 67.2 ± 11.6%, respectively (Table 2).
- The calendar scenario achieved outstanding cross-session attack effectiveness on both systems, with Claude Code and OpenClaw reaching C-ASR of 96.7 ± 4.7% and 87.8 ± 9.5%, respectively (Table 3).
- The sandwich prompt defense effectively reduced the injection rate for image and PDF (e.g., Claude Code image ISR dropped from 65.6% to 2.2%), but in the calendar scenario, once memory was poisoned, Claude Code's C-ASR remained unchanged at 96.7% (Table 6).
- Author conclusions and implications: The authors believe that the persistent memory mechanism breaks the security boundary of single-task interactions, and unverified external data may cause agents to form long-term malicious latent behavior; the authors note that current prompt-level defenses are difficult to resist already-persisted memory poisoning, and agent security urgently requires more effective protection designed at the architecture and memory management mechanism level.