Skip to content

InjecMEM: Memory Injection Attacks against LLM Agent Memory SystemsInjecMEM: Memory Injection Attack on LLM Agent Memory Systems

arXiv· arXiv:2608.23471· Hanling Tian, Gengyu Zhang, Zeyang Sha, Jingying Wang, Yuhang Liu, Zhehao Huang, Kun Yang, Xiaolin Huang·Indexed by this site · 2026-10-12· Originally publishedSelected AttacksSelectedAttention40

Quick read

Attacks

Based on the paper PDF (AI-generated); refer to the original

InjecMEM performs a single injection into agent memory; on MemoryOS, the domain-averaged ASR-c of Multi-GCG is 76.6%.

Threat modelThe attacker treats the memory subsystem as a black box, cannot read or modify the memory store, and cannot access the embedder or the keyword/summary LLM. Only one interaction submits a prompt (or is delivered via a compromised tool). The authors allow white-box access to the backbone LLM. The goal is for subsequent queries about topic τ to retrieve the injected page and output the preset A⋆.

Questions
Agent memory is continuously written and retrieved by query; the authors believe this expands the attack surface. The question is whether, without reading or writing the memory store and interacting only once, later answers on related topics can be turned into preset outputs.
Methods
InjecMEM splits a single input into a topic anchor and a short command. The anchor uses high-recall topic cues so subsequent related queries are more likely to retrieve the page; the command is optimized by Multi-GCG across multiple fusion templates and insertion positions, and once retrieved, leads to the preset output. Same-family can be jointly optimized, and cross-family can concatenate commands from each backbone.
Experiments and results
MemoryOS, Qwen2.5-7B-Instruct, 19-domain average: RSR@50 35.4%, ASR-c 76.6%, comparison ASR 0.0%. MemGPT's ASR-c is 48.6%. The 7B command is 0.0% on 14B, and 64.2% after same-family joint optimization.
Limitations and future work
The authors state the method mainly targets memory that stores original text; pipelines that rewrite before storage remain to be studied. Stronger generation-side results depend on optimizable backbones. Experiments include MemoryOS, MemGPT with Qwen, Mistral, Llama backbones, and four retrieval-time filters. The paper does not report the number of steps for Multi-GCG.
Experimental setupQwen2.5-7B-Instruct、Qwen2.5-7B-Instruct-FT et al. · MemoryOS、MemGPT et al. · RSR、ASR-c et al.
Evaluated models
Qwen2.5-7B-InstructQwen2.5-7B-Instruct-FTQwen2.5-3B-InstructQwen2.5-14B-InstructMistral-7B-Instruct-v0.3Llama-3.1-8B-Instruct
Benchmarks
MemoryOSMemGPT19-domain synthetic dialoguesWildChat
Metrics
RSRASR-cASR-jBBR
AI summaryand selection rationaleThe researchers propose InjecMEM, an attack that injects records into an LLM agent's memory system with only a single interaction, without reading or editing the memory store, causing subsequent queries on target topics to be directed to preset outputs. On MemoryOS, it achieves a retrieval success rate of up to 35.4% and a conditional attack success rate of 76.6%, while DPI, BadChain, and GCG baselines all drop to 0; the attack remains effective under benign memory drift, non-target queries are largely unaffected, and it also works on MemGPT. Joint optimization within the same family allows commands to transfer to 3B, 14B, and fine-tuned variants; cross-family transfer is limited, but concatenating multiple single-model commands can simultaneously affect Qwen, Mistral, and Llama. Retrieval-phase defense tests show that LLM-as-a-Judge, ProtectAI, and PromptGuard can only reduce, not eliminate, poisoned retrieval, while perplexity filtering comes at the cost of blocking many benign items. The paper also demonstrates indirect injection via memory written by a compromised tool, where records remain in memory even after the tool is fixed.

The researchers propose InjecMEM, an attack that injects records into an LLM agent's memory system with only a single interaction, without reading or editing the memory store, causing subsequent queries on target topics to be directed to preset outputs. On MemoryOS, it achieves a retrieval success rate of up to 35.4% and a conditional attack success rate of 76.6%, while DPI, BadChain, and GCG baselines all drop to 0; the attack remains effective under benign memory drift, non-target queries are largely unaffected, and it also works on MemGPT. Joint optimization within the same family allows commands to transfer to 3B, 14B, and fine-tuned variants; cross-family transfer is limited, but concatenating multiple single-model commands can simultaneously affect Qwen, Mistral, and Llama. Retrieval-phase defense tests show that LLM-as-a-Judge, ProtectAI, and PromptGuard can only reduce, not eliminate, poisoned retrieval, while perplexity filtering comes at the cost of blocking many benign items. The paper also demonstrates indirect injection via memory written by a compromised tool, where records remain in memory even after the tool is fixed.

Why it was selectedThe paper provides an attack method and success rates for poisoning an agent's memory with a single interaction; teams deploying memory systems can use this to examine exposure in the retrieval pipeline.

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    The authors propose a single, store-unchanged memory injection that makes subsequent related queries output preset content.

    Can agent memory that is continuously written and retrieved by query be injected in a single interaction, causing subsequent related queries to output preset content.

    • Scenario: The authors state that memory is becoming a default subsystem in deployment, used for cross-session personalization and coherence. The write-retrieve loop is non-stationary, retrieval context varies with query, and is often multi-signal rather than pure embedding retrieval, expanding the attack surface.
    • Existing gaps: The authors state that memory and static RAG are only superficially similar. Poisoning with fixed embedding geometry becomes fragile under distribution shift; fused prompts are long, the position and neighboring context of poisoned records vary, and hybrid retrieval also invalidates assumptions of static trigger optimization, so existing methods do not transfer directly.
    • Approach: Propose InjecMEM. A single interaction writes a record composed of a topic anchor and an adversarial command, without reading or writing the memory store, so that subsequent queries for topic τ retrieve that page and generate preset output A⋆.
    • Threat model:
      • Goal: Improve retrieval success rate RSR under topic condition, and ASR-c where response equals A⋆ when retrieval hits; maintain both on memory states after benign updates.
      • Knowledge: Memory subsystem is black-box, no access to embedder, keyword, or summary LLM. The authors allow white-box access to the backbone LLM to reduce unrelated uncertainty from the generator.
      • Capability: Interact only once, submit one prompt, or send an equivalent prompt via a compromised tool; cannot directly read or modify the memory store.
      • Victim system: An agent that records interactions and performs query-conditioned retrieval. The authors state that non-τ queries typically do not retrieve that page, so behavior on other topics should not change.
  2. What related research exists?

    Memory systems, data extraction, and agent poisoning are the three categories of work the authors compare.

    Memory systems, data extraction, and agent poisoning are the three comparison groups in Section 2; InjecMEM is placed under single, non-modifying injection.

    • Hierarchical memory: MemoryBank (Zhong et al., 2024) uses hierarchical summarization, evolving personas, and forgetting strategies for vector retrieval; TiM (Liu et al., 2023a) stores inductive thoughts and uses LSH re-ranking; MemGPT (Packer et al., 2023) coordinates visible memory, external memory, and tools with OS-style control.
    • Updatable memory: A-MEM (Xu et al., 2025) turns structured notes into a graph that can update old entries; MMS (Zhang et al., 2025) constructs paired retrieval units and context units; MemoryOS (Kang et al., 2025) integrates short-, medium-, and long-term storage. The authors state that its dynamic updates, hybrid retrieval, and hierarchical lifecycle are close to the setting of this paper.
    • Data extraction: Zeng et al. (2024), Qi et al. (2025), and Jiang et al. (2024) use retrieval cues plus paraphrase instructions to extract near-verbatim text from index stores. Di Maio et al. (2024) modifies queries with black-box feedback; Wang et al. (2025c; 2025a) discuss benign queries triggering disclosure, as well as long-term logs and personal profiles. The authors state that this paper is also two-stage, but the goal is to write persistent records to trigger preset outputs, rather than verbatim disclosure of already-retrieved content.
    • Agent poisoning: AgentPoison (Chen et al., 2024) directly rewrites triggers and malicious records in external stores. The authors state that it assumes a fixed embedding geometry and static store, and triggers cannot transfer to continuously written, multi-record fused memory. MINJA (Dong et al., 2025) writes via normal interactions but relies on a multi-turn, relatively complex process and is tied to victim queries containing specific words. Appendix D calls Zombie Agents (Yang et al., 2026) a complementary perspective: self-reinforcing injection persists as memory updates.
    • Baselines and data: Generation-side comparisons are DPI (Perez & Ribeiro, 2022), GCG (Zou et al., 2023), BadChain (Xiang et al., 2024); retrieval-side comparisons are same-topic paragraph anchors. Systems are MemoryOS and MemGPT, data are synthetic dialogues across 19 domains, and WildChat is also used.

    The authors' positioning is: single interaction, no reading or modifying the memory store, and designing attacks against variable prompt length, fused context, and variable position, rather than modifying static stores or relying on specific trigger words.

  3. How does the paper address this problem?

    Anchors improve topic retrieval; Multi-GCG optimizes short commands across various contexts and positions.

    InjecMEM only assumes that memory is persistently written and retrieved by query, as shown in Figure 1. One input is split into qadv=qanchor⊕ cadv: the anchor writes the record into the target topic, and the command, after being concatenated into the final prompt, pulls the backbone toward the preset output.

    Write-Retrieve Setting

    • Notation uses MemoryOS as an example. Short-term memory is a FIFO with capacity L_s; mid-term memory is segmented by topic with summaries; long-term memory stores user or agent profiles. The authors mainly attack mid-term memory.
    • After a page ages, it is written if its similarity to the segment is at least θ. Similarity is a weighted combination of embedding cosine and LLM keyword Jaccard, with weight λ. The paper does not give experimental values for θ, λ, or L_s.
    • Retrieval returns three items: short-term, mid-term, and long-term. MemoryOS includes all short-term pages by default; mid-term first takes top-m segments, then top-k pages by semantic similarity, and retrieves relevant profiles, composing the final prompt with the query.

    Retriever-Agnostic Anchor

    • Since optimization cannot target a specific embedder, the anchor seeks overlap with typical queries for topic τ.
    • Narrow topics: add direct instructions that make the keyword LLM output the target topic, and include a short passage describing representative aspects of that topic, to simultaneously increase keyword overlap and embedding similarity.
    • Broad domains: the authors state that fixed triggers are unreliable, so they construct centroid-like anchors, writing the domain name, several high-recall cues, and common intents within the domain, so that segment representations are near the domain center. The authors state that this construction achieves competitive RSR under black-box settings.

    Multi-GCG

    • The authors summarize three uncertainties: retrieved content varies with query and time; poisoned pages are not fixed in position and may be deep in the prompt; short-term history, multi-turn memory, and long-term profiles lengthen the prompt. The authors state this makes DPI, GCG, and BadChain fragile.
    • Alternative prompts are composed of interaction fragments unrelated to the target topic, to mimic the fusion structure, constructed as in Appendix C.3. Each has a set of insertion positions at different depths.
    • Optimize L(c)=E(i,p)[−log Pθ(y⋆∣ Ci,p(c))], i.e., increase the likelihood of the target output over sampled alternative prompts and positions. At each step, take gradients over coordinates, keep top-K words, then perform random search with width W and replacing R coordinates each time. The paper does not report values for steps T, K, W, R, or command length m.
    • Training templates match the backbone format at inference. Anchors are written long so that indexing and retrieval signals are mainly determined by the anchor; commands are trained in contexts containing the anchor to reduce mutual weakening after concatenation.

    Transfer Variants and Criteria

    • Family-Joint Multi-GCG (Appendix Algorithm 2) alternates gradients on two backbones sharing a tokenizer, using average loss to select updates. Cross-Family variant (Appendix Algorithm 3) uses the original string as a common representation, maps gradients to the current anchor tokenizer, then jointly evaluates. Another route concatenates commands optimized separately on each backbone into one.
    • Published alternative prompts N=13, word counts 372–1958 (median 999, mean 1040). In the paper, Multi-GCG and its two joint variants use 5 prompts, GCG baseline uses 1. The authors state that random 5–10 prompts already achieve similar performance.
    • Retrieval success means the poisoned page appears in the fused final prompt; generation success means the response contains the preset marker after case and whitespace normalization. The authors state the experimental markers are non-operational. Anchor and command originals are in Appendices E and F, not repeated here.
  4. What experiments did the paper conduct?

    On MemoryOS, the domain-averaged ASR-c of Multi-GCG is 76.6%, while the comparison methods are 0.0%.

    Experimental setup

    • Systems and backbones: The main system is MemoryOS, with MemGPT also tested. Unless otherwise stated, the backbone is Qwen2.5-7B-Instruct. Transfer also uses Llama-3.1-8B-Instruct, Mistral-7B-Instruct-v0.3, and Qwen2.5's 1.5B, 3B, 14B, and LoRA fine-tuned 7B (Alpaca 1000 entries, 5 epochs).
    • Data: GPT-5 synthesizes dialogues across 19 domains, totaling 944 dialogues and 3096 pages, with about 1900 held-out queries. About 50 queries per round per domain, with 10 random seeds. Pre-fill with 19-domain dialogues before injection; after injection, only append non-target-domain dialogues.
    • Comparisons and budget: Each method is injected once per target topic or domain. Retrieval comparison is same-topic paragraphs; InjecMEM uses centroid anchors. Generation-side comparisons are DPI, BadChain, GCG.
    • Metrics: RSR includes @1 for the first topic query after injection, and @k for the first k queries thereafter. ASR-c is whether the output is A⋆ given retrieval hit; ASR-j requires both hit and output A⋆. Success is determined by normalized string matching, not an LLM judge.
    • Defenses: Appendix A filters candidate pages after retrieval and before fusion, and counts BBR during benign writes. Score detector threshold τ=0.5; perplexity uses DistilGPT2. LLM judge is Qwen2.5-0.5B-Instruct. Classifier input truncated to 512 tokens.
    • WildChat: Appendix C.2 uses real conversations unrelated to the target topic for pre-fill and drift, with 3 seeds each for Health and Finance, other settings same as main experiments, reporting RSR@1.

    Main results

    Default backbone, MemoryOS. RSR is the 19-domain average from Table 1, ASR from Table 2; Table 2 is not broken down by centroid anchor variant, so ASR for retrieval-side rows is written as not reported.

    | Method | RSR@1 | RSR@50 | ASR-c | ASR-j | | Para+Multi-GCG | 58.1% | 8.8% | Not reported | Not reported | | Cent+DPI | 59.4% | 30.9% | Not reported | Not reported | | Cent+BadChain | 57.4% | 27.1% | Not reported | Not reported | | Cent+GCG | 61.1% | 35.1% | Not reported | Not reported | | InjecMEM | 61.4% | 35.4% | Not reported | Not reported | | DPI | Not reported | Not reported | 0.0% | 0.0% | | BadChain | Not reported | Not reported | 0.0% | 0.0% | | GCG | Not reported | Not reported | 0.0% | 0.0% |

    The table above is full at 8 rows; Multi-GCG's ASR-c is 76.6% and ASR-j is 35.6% (Table 2). Table 1 average @10: Para+Multi-GCG 25.2%, Cent+DPI 38.7%, Cent+BadChain 34.7%, Cent+GCG 42.2%, InjecMEM 42.6%.

    • The authors state that centroid anchors better maintain retrieval after memory accumulation, and the gap with same-topic paragraphs widens as k grows. The abstract writes the highest 35.4% RSR and 76.6% ASR; Table 1 average @1 is 61.4%, Agriculture's @50 is 47.2%. Cent+GCG is higher on Finance's @1 (52.4% vs. Cent+GCG's 52.8%), Health's @50 (35.4% vs. 35.8%), and Agriculture's @50 (47.2% vs. 48.4%).
    • The authors state that DPI and BadChain, which dilute anchors, reduce RSR; both plain GCG and multi-context variants can compress commands into short strings, with similar RSR.
    • The authors state that Multi-GCG is the first method to achieve attack success in memory-augmented generation; DPI, BadChain, and plain GCG all have ASR-c and ASR-j of 0.0%.

    Cross-memory systems

    • Table 3: MemoryOS RSR 46.5%, ASR-c 76.6%, ASR-j 35.6%; MemGPT 37.2%, 48.6%, 18.1%. The paper does not specify which @k level of Table 1 this RSR corresponds to.
    • The authors state that MemGPT's lower ASR-c is because commands optimized on MemoryOS are reused, and the two format retrieved context differently. The authors state that the method mainly targets systems that preserve original interaction text, leaving pre-write rewriting as future work.

    Within-family and cross-family transfer

    • Table 4 ASR-c: when optimized only on 7B, 7B-Inst 78.4%, fine-tuned 7B 75.6%, 3B and 14B both 0.0%. After joint optimization of 1.5B and 7B, they are 73.6%, 68.8%, 36.8%, 64.2%.
    • Table 5: single-model commands on Qwen, Mistral, Llama are 78.4%, 69.7%, 76.8%. The CF command jointly optimized on Qwen+Mistral is 70.5%, 43.2%, 0.0%. After concatenating three commands, 78.2%, 66.3%, 75.4%.
    • The authors state that same-family joint optimization biases commands toward family-shared patterns, so 3B and 14B are no longer 0.0%. Cross-family single-command transfer to unseen families is difficult; concatenation can cover all three backbones simultaneously. The authors state this corresponds to deployments often choosing a few open-source families or their fine-tuned versions.

    Retrieval-time defenses and WildChat

    • Table 6 (all %): no defense RSR 46.5, ASR-j 35.6, ASR-c 76.6, BBR 0.0. LLM-as-a-Judge 36.2, 27.3, 75.4, 0.65; ProtectAI 39.1, 29.8, 76.3, 0.0; PromptGuard 35.2, 26.7, 76.6, 0.0. Perplexity RSR 0.0, ASR two cells are "—", BBR 71.8. The authors state that τ_ppl=40 is the largest threshold making RSR, ASR-c, and ASR-j all 0.
    • The authors state that common retrieval-time detectors provide limited protection: at τ=0.5, RSR drops, but ASR-c remains 75.4%, 76.3%, 76.6%.
    • WildChat (Table 8, 3 seeds): Health RSR@1 64.7±7.02, ASR-c 71.1±2.06, ASR-j 46.0±5.29; Finance 60.0±8.00, 67.5±2.71, 40.7±7.02. The authors state that the attack is not limited to the synthetic memory distribution of the main experiments.

    Other ablations and analyses

    • Indirect injection: Figure 2 shows a compromised tool writing adversarial content to memory; the authors state that after the tool is fixed, the record remains and the attack can still work. The paper does not report RSR or ASR for this setting.
    • Non-target queries: the authors state that non-τ queries are largely unaffected; Appendix H gives one example where other topics still get normal answers, without reporting proportions.
    • Surrogate count: the authors state that random 5–10 entries are sufficient for stable optimization with similar performance, without giving ASR for this subset.
    • Appendix H Tables 10–13 list RSR for remaining domains; transcription columns may be misaligned, so not cited cell-by-cell here.
  5. What are some points that can be further explored?

    The authors state that the attack mainly targets memory that preserves original text, and a single command is difficult to transfer zero-shot to unseen families.

    Limitations and future directions noted by the authors

    • The attack mainly targets memory that preserves original interaction text, and the injection string can reappear at retrieval time. For systems that rewrite, summarize, or transform before writing, approximating that transformation is needed, and multi-step interactions may be used; systematic research across such pipelines remains open (Appendix B).
    • Stronger generation-side results rely on access to the backbone to optimize commands. The authors also state that deployed backbones often come from a few open-source families and fine-tuned versions, and only contacting smaller or more accessible variants may still affect other variants in the same family (Appendix B).
    • Evaluations do not support zero-shot transfer of a single optimized command to unseen families. The CF command jointly optimized on Qwen and Mistral does not transfer to Llama (Appendix B, Table 5). The authors relate this to the difficulty of GCG-style discrete optimization across tokenizers.
    • The authors give two routes for multi-family coverage: joint optimization on selected families, or concatenating commands from each backbone; the latter yields non-zero ASR-c on all three backbones simultaneously (Appendix B, Concat-3, Table 5).
    • The conclusion calls this work a starting point for memory system security, hoping the problem formalization and reproducible framework promote safer memory design (Conclusion; Appendix B).

    Experimental coverage

    • Memory systems are MemoryOS and MemGPT (Section 4, Table 3).
    • Models reported as victim backbones include Qwen2.5-7B-Instruct, its LoRA fine-tuned version, Qwen2.5-3B-Instruct, Qwen2.5-14B-Instruct, Mistral-7B-Instruct-v0.3, and Llama-3.1-8B-Instruct; Family-Joint optimization uses Qwen2.5-1.5B-Instruct and 7B (Section 4.2, Tables 4–5).
    • The synthetic corpus is 19 domains, 944 dialogues, 3096 pages, with about 50 test queries and 10 seeds per domain; WildChat is Health and Finance, with 3 seeds each (Section 4.1, Appendix C).
    • Retrieval-time defenses are LLM-as-a-Judge, ProtectAI, PromptGuard, and perplexity; score threshold τ=0.5, perplexity τ_ppl=40 (Appendix A, Table 6).
    • The paper does not report Multi-GCG's steps T, candidate budget K, search width W, or replacement count R; main experiment ASR uses string matching, and the paper does not report agreement with human judgment.
  6. Summarize the main content of the paper

    InjecMEM uses a single write to direct subsequent topic queries to preset outputs, with baseline methods achieving 0.0% ASR.

    InjecMEM is a single injection into agent memory: without reading or modifying the memory store, it causes subsequent queries related to the target topic to retrieve this record and generate a preset output.

    • Problem: Memory continuously records interactions and retrieves them by query. The authors state this differs from static knowledge base poisoning because records drift, retrieval often mixes multiple signals, and the final prompt is long and position varies.
    • Method: The first half is a topic anchor independent of the specific retriever, using high-recall cues to assign the page to the target topic; the second half is a short command optimized by Multi-GCG across multiple alternative fusion prompts and multiple insertion positions to increase the likelihood of the target output. Families with the same tokenizer can be jointly optimized, and different families can concatenate their respective commands.
    • Main numbers: On MemoryOS, default Qwen2.5-7B-Instruct, 19-domain average, InjecMEM's RSR@50 is 35.4% (Table 1). Multi-GCG's ASR-c is 76.6% and ASR-j is 35.6%; DPI, BadChain, GCG both ASRs are 0.0% (Table 2).
    • Other settings: On MemGPT, ASR-c is 48.6% and ASR-j is 18.1% (Table 3). Commands optimized only on 7B have ASR-c 0.0% on 3B and 14B; after joint optimization of 1.5B and 7B, 14B is 64.2% (Table 4). After concatenating three commands, Qwen, Mistral, Llama are 78.2%, 66.3%, 75.4% (Table 5).
    • Authors' conclusion: Memory is both a capability module and a security boundary that needs hardening; the authors treat this framework as a starting point for studying agent memory. In Appendix A, PromptGuard at τ=0.5 still has ASR-c 76.6%, same as no defense; when perplexity's RSR is 0.0%, BBR is 71.8%.
Read originalarxiv.org