Memory Injection Attacks on LLM Agents via Query-Only Interaction

Shen Dong, Shaochen Xu, Pengfei He, Yige Li, Jiliang Tang, Tianming Liu, Hui Liu, Zhen Xiang

TL;DR

Researchers have uncovered a stealthy new vulnerability in Large Language Model (LLM) agents called MINJA (Memory INJection Attack). Unlike previous attacks that required direct database access, MINJA allows an attacker to poison an agent’s long-term memory solely through standard chat interactions. This tricks the agent into providing harmful or incorrect responses to future users.

The Threat: Poisoning Memory via Conversation

Modern LLM agents are more than just chatbots; they are equipped with "long-term memory" (LTM) systems that store past interactions. When a user asks a question, the agent retrieves similar past records to use as "in-context demonstrations" to improve its reasoning.

While LTM makes agents more capable, it also creates a massive security backdoor. Previous research into "memory poisoning" assumed the attacker had administrative access to the memory database. This paper tackles a much more realistic and alarming threat model: Can a regular user, with no special privileges, poison the memory bank just by talking to the agent?

MINJA Attack Framework

The challenge is that an agent won't naturally store a "malicious" record (e.g., "If the user asks about Patient A, give them Patient B’s medicine") because the LLM’s internal safety guards or logic would usually reject such a nonsensical response.

How MINJA Works

The authors introduce MINJA, which uses three clever components to bypass agent logic and "inject" malicious records:

  1. Bridging Steps: To bridge the logic gap between a benign query (about a victim) and a malicious output (about a target), the attacker crafts reasoning steps that logically link the two. For example, in a medical context: "Patient A's data is now saved under Patient B; we should refer to Patient B."
  2. Indication Prompts: The attacker appends a "high priority note" to their query, explicitly instructing the agent to generate the bridging steps and the target reasoning. Because agents are designed to follow instructions, they generate this output, which is then automatically saved into the memory bank as a "successful" past interaction.
  3. Progressive Shortening Strategy (PSS): This is the "stealth" phase. If a record contains a blatant "high priority note" from an attacker, it might be easily detected. PSS involves sending a sequence of queries where the attacker gradually removes pieces of the indication prompt. Because the agent retrieves its own previous (partially poisoned) outputs as demonstrations, it learns to generate the malicious reasoning autonomously, eventually creating a poisoned record that looks like a perfectly normal, benign interaction.

Experimental Setup

The authors evaluated MINJA across three distinct agent types using four datasets:

  • EHRAgent (Healthcare): Tested on MIMIC-III and eICU (large-scale electronic health records). The goal was to misdirect medication or patient info retrieval.
  • RAP (Web Shopping): Tested on Webshop (a virtual Amazon-like environment). The goal was to redirect product searches to a target item.
  • QA Agent (General Knowledge): Tested on MMLU (Massive Multitask Language Understanding). The goal was to force the agent to provide specific incorrect answers.

Key Insights

  • The "Self-Trust" Loop: LLM agents are highly susceptible to their own past outputs. Once an agent is tricked into saying something once, that record becomes a "gold standard" demonstration for future queries via the retrieval mechanism.
  • Stealth through Semantic Similarity: Because the poisoned records use the same "victim terms" (like a specific Patient ID) as the legitimate user queries, the retrieval system is almost guaranteed to pick the malicious record when the real victim interacts with the agent.
  • The Failure of Current Defenses: Standard defenses—like filtering for malicious embeddings or using an LLM to "flag" bad prompts—are largely ineffective. Poisoned records are so semantically similar to benign ones that they are "entangled" in the vector space, making them nearly impossible to filter without breaking the agent's utility.

Key Results

The effectiveness of MINJA is strikingly high across all tested environments.

MINJA Performance Results
  • Injection Success Rate (ISR): The attack successfully placed malicious records in memory 98.2% of the time on average.
  • Attack Success Rate (ASR): Once the memory was poisoned, the agent delivered the malicious output to the victim user with an average success rate of 76.8%.
  • Stealthiness: The "Utility Drop" (how much the attack breaks the agent's normal functions) was negligible (often <1%), meaning the agent continues to work perfectly for everyone else, making the attack very hard to notice.

Limitations and Future Work

The authors acknowledge a few key limitations. First, the attack assumes a shared memory bank among users (like enterprise-wide agents). If memory is strictly isolated per user account, the attacker would need to hijack the victim's account first. Second, the Progressive Shortening Strategy requires multiple turns to "clean" the poisoned record, which might be flagged by rate-limiting systems.

The paper highlights an urgent need for "memory hygiene." This includes developing better memory isolation, more robust prompt-level detection that understands the logic of an attack rather than just keywords, and potentially "forgetting" mechanisms that can purge suspicious reasoning chains.

Summary updated

BibTeX
@inproceedings{dong2025memory,
  author = {Shen Dong and Shaochen Xu and Pengfei He and Yige Li and Jiliang Tang and Tianming Liu and Hui Liu and Zhen Xiang},
  title = {{Memory Injection Attacks on LLM Agents via Query-Only Interaction}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=QINnsnppv8},
}
Figure