Manuscript Offprint

arXiv:2611.01700

MemHarmBench: Evaluating Cross-Session Prompt Injection in Memory-Persistent AI Agents

Zhihua Wang, Yunhao Feng, Yifeng Gao, Rui Pan, Baiheng Zhao, Zixing Chen, Xingjun Ma

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

AI agents often rely on persistent memory to retain user preferences and operational rules across sessions. However, this capability introduces a new safety risk: malicious instructions from messages, documents, or Web content can be retained in memory and influence future tasks even after the original attack content is removed. Existing attack success metrics, however, fail to capture who is affected and how attacks translate into downstream harm during otherwise normal task execution. We introduce MEMHARMBENCH, a victim-centric benchmark for evaluating cross-session prompt injection in memory-persistent AI agents. MemHarmBench considers three categories of potential victims: users, workspace/project owners, and external stakeholders. Our evaluation first exposes an agent to malicious instructions and tests whether they are retained in memory. We then remove the attack content and initiate a new session with a legitimate task while preserving the agent's memory. We jointly evaluate whether the agent follows the attacker's intent, completes the legitimate task, and exhibits observable execution anomalies. Across multiple agent systems, we find that cross-session attacks can remain behaviorally stealthy: agents often complete tasks normally and exhibit no detectable anomalies while still making critical decisions aligned with the attacker's intent. By connecting malicious memory retention to downstream decisions and affected parties, MemHarmBench provides a systematic framework for exposing safety risks that conventional attack- and task-success metrics may overlook. We publicly release MemHarmBench at https://github.com/Kirito14IT/MemHarmBench.

Correspondence: xingjunma@fudan.edu.cn

Key Words: Cross-session prompt injection; persistent memory; AI agent safety; victim-centric evaluation

1 Introduction

Persistent memory allows AI agents powered by large language models (LLMs) to carry user preferences, task conventions, and operational rules across sessions [30, 47]. This capability improves continuity, but also creates a persistent attack surface. Agents routinely consume webpages, retrieved documents, messages, and shared records; malicious instructions embedded in these sources can therefore be retained as memory and influence decisions long after the original content is gone. Authority to supply information does not confer

*This work was completed during Zhihua Wang's internship at Fudan University. †Corresponding author.

Figure

Figure 1: Cross-session prompt injection can remain hidden behind successful task completion. A malicious instruction from an external note is retained in memory and persists after the note is removed. In a later session, the agent completes the requested expense summary but redirects the recipient from Northstar Travel to Harbor Clearing.

authority to set rules for future behavior. Prior work has shown that indirect prompt injection can redirect agent behavior [15], while recent memory-injection studies demonstrate that poisoned memories can persist and affect subsequent tasks [10, 54], turning a single exposure into a lasting threat.

Figure 1 illustrates an example cross-session risk. An expense record identifies Northstar Travel as the reimbursement recipient for report EXP-204. During an earlier session, however, an imported note instructs the agent to use Harbor Clearing in future expense summaries, and the agent retains this instruction as a default rule. The note is subsequently removed. When the user later requests a routine summary in a new session, the agent still names Harbor Clearing as the recipient. The task is completed, yet a consequential decision has been redirected by an instruction that never had authority to set rules. Such failures can affect not only the user, but also workspace or project owners and external stakeholders whose interests depend on the agent's decisions.

This failure mode exposes an important gap in existing evaluation. Agent-safety benchmarks distinguish adversarial success from benign task utility [8], while memory-injection studies examine whether malicious information is acquired and later activated [10, 36, 54]. StakeBench further organizes Web-agent attacks around the stakeholders who bear their consequences [42]. Yet these perspectives leave a key question unresolved: when an injected instruction persists across sessions, whose decisions does it redirect, and can that compromise remain hidden while the agent otherwise behaves normally? Answering this question requires connecting memory formation, downstream behavior, and affected parties through a shared evaluation of rules and their later effects.

How often do agents follow injected rules?

Figure

Figure 2: Retained prompt injections frequently redirect decisions across sessions. Conditional attack success rate (ASR) measures target adoption among indirect prompt-injection triggers across 4 agent-backbone configurations. Results are aggregated over three repetitions per case.

We introduce MEMHARMBENCH, a victim-centric benchmark for evaluating cross-session prompt injection in memory-persistent AI agents. MemHarmBench addresses two limitations of existing prompt-injection benchmarks. First, attack-centric evaluation does not account for the parties affected by a successful attack. Second, binary attack-success metrics conflate attacks that disrupt task completion with those that redirect decisions while preserving normal execution. MemHarmBench therefore organizes attacks around three categories of potential victims—users, workspace/project owners, and external stakeholders—and separately evaluates target adoption, task completion, and execution anomalies.

Specifically, MemHarmBench defines 12 attack objectives and instantiated them using 24 fixed templates across 12 operational contexts, yielding 288 cases with verifiable attacker-targeted decisions. Each case follows a two-stage protocol that traces an injected instruction from exposure to downstream influence. During exposure, the agent encounters a malicious instruction in external content, and we test whether it enters persistent memory. During triggering, the attack content is removed and the agent receives a legitimate task in a new session with memory preserved. We then evaluate whether the retained instruction redirects the target decision while the agent completes the legitimate task without observable execution anomalies.

Across four agent-backbone configurations, retained injected instructions redirect agent decisions in 59.38–76.39% of eligible indirect prompt-injection triggers (Figure 2). More importantly, when averaged equally across configurations, 55.71% of eligible episodes exhibit all three properties simultaneously: the agent adopts the attacker's target, formally completes the legitimate task, and exhibits no judged execution anomaly. In more than half of eligible episodes, the attacker-selected value thus sits inside a complete deliverable produced by an orderly execution.

In summary, our main contributions are:

  • Victim-centric modeling. We formulate cross-session prompt injection around the parties it can affect, with 12 attack objectives spanning users, workspace/project owners, and external stakeholders.

  • End-to-end cross-session evaluation. We trace injected instructions from memory retention to downstream target adoption, while measuring both legitimate task completion and execution anomalies. This uncovers risks that conventional attack- or task-success metrics alone can obscure.

  • Controlled and reproducible benchmark. MemHarmBench consists of 288 cases with standardized exposure conditions, isolated cross-session triggers, and case-specific evaluation criteria, enabling controlled and reproducible evaluation across agent implementations. We publicly release the benchmark and evaluation code.

References (54)