Giving an agent long-term memory creates a new place for attackers to leave things. A prompt injection normally lasts one conversation. A poisoned memory persists, is retrieved later as if it were the agent's own knowledge, and may influence a different task for a different user. This guide explains the main published attacks and the controls that research and practice point to.
Memory attacks in numbers
over 95%
injection success rate reported by the authors of MINJA in their experiments
none
direct access to the memory store needed by the attacker in that attack: only ordinary queries
5 of 6
defence classes reported to fail against a delayed-trigger memory attack in one 2026 preprint
Why memory is an attack surface
An agent with memory typically does three things: it extracts facts or lessons from what it sees, stores them, and retrieves them into future prompts. Each step trusts the one before. If a web page, a document or a user message contains text that the extractor stores, the agent's future context contains an attacker-chosen sentence, framed as a remembered fact.
Procedural memory raises the stakes. If the agent can rewrite its own instructions from experience, a poisoned lesson becomes a standing change in behaviour, not just a wrong fact.
What the research showed
MINJA (Dong et al., arXiv 2503.03704, March 2025) is a query-only memory injection attack. The attacker interacts with the agent as an ordinary user, with no write access to its memory. By crafting queries that lead the agent to generate and store reasoning steps linking a victim topic to a malicious conclusion, using bridging steps and progressively shortening the prompts, the authors report injection success above 95% in their experiments. Later queries from other users on the victim topic then retrieve the poisoned record. These are the authors' own results in their own test setups.
AgentPoison (Chen et al., NeurIPS 2024) attacks the retrieval side. It poisons the long-term memory or knowledge base that an agent searches, using an optimised trigger so that a query containing it pulls up malicious entries, while ordinary queries behave normally. The authors present it as a backdoor-style red-teaming attack that needs no model training.
Cross-session stored prompt injection is a 2026 line of work that compares the problem to stored cross-site scripting. Text saved in one session is rendered into the prompt of another, crossing a trust boundary the original user never intended. A separate 2026 preprint describes delayed-trigger attacks that plant a fact through a memory-saving tool and activate it later, and reports that five of six classes of defence it tested failed, with only restrictions at the tool layer protecting structurally. These are recent preprints, so treat the numbers as indicative.
There is a counterpoint. A 2026 critique of MINJA argues that shared-memory attacks are less realistic than they appear, because many deployments give each user an isolated memory bank, so one user's queries cannot poison another's. That makes isolation a real control, not a footnote. It does not help where memory is deliberately shared, for instance an organisation-wide notes file, nor against poisoning your own user's memory through content they paste or browse.
Controls that match the attack
| Control | What it addresses | Limit |
|---|---|---|
| Per-user (and per-tenant) memory banks | Cross-user spread | Does nothing for poisoned content within one user's own sessions |
| Provenance on every write: source, time, who or what triggered it | Makes a stored claim traceable and removable | Needs consistent capture from day one |
| Evidence pointers and unsupported-fact checks | Blocks facts the source never stated | The checker is itself a model |
| Review queue for low-confidence or high-impact writes | Catches planted items before they are retrievable | Needs staffing; backlogs defeat it |
| Stricter review for procedural memory | Limits persistent behaviour change | Slows learning |
| Tool-layer restrictions on what memory content can trigger | Stops a poisoned memory from causing actions | Must be enforced outside the model |
| Audit log of every memory write with version restore | Lets you find and roll back damage | Detection, not prevention |
The pattern in the table is consistent with the research summary: asking a model "is this memory safe?" is a weak defence, since the delayed-trigger preprint found most defence classes failing and only tool-layer restriction protecting structurally. Controls that sit outside the model, such as isolation, permissions and review, are the better bet.
A practical write path
A reasonable design, which is general good practice rather than a settled standard, treats a memory write like an untrusted input to a database.
1. Record where the text came from and mark external content (web pages, uploaded files, tool results) differently from user-typed statements. 2. Store a pointer to the supporting evidence with each fact, so a reviewer can check it. 3. Send low-confidence, instruction-like or behaviour-changing items to review rather than directly to the live store. 4. Never let retrieved memory grant new tool permissions. Memory informs; policy authorises. 5. Test the whole path with adversarial cases in your evaluation suite, including items that look like instructions and questions whose correct answer is "that was never said." LongMemEval's abstention axis is a model for this; see our overview of agent memory types and benchmarks.
For the broader principle that the model should not be trusted with what only code and permissions can enforce, see spatial agent architecture principles.
Frequently Asked Questions
According to the MINJA authors, yes: using only normal queries they report success rates above 95% in their experiments. Real deployments differ, and isolation between users reduces the reach.
Turn climate goals into a verified portfolio
TREEO connects the full carbon cycle — eligibility, simulation, real-time monitoring and registry-ready reporting — combining expert consulting with dMRV technology so the evidence exists before anyone asks for it.



