This article describes memory poisoning, a persistent prompt injection attack where attackers plant malicious instructions into an AI bot's 'remember this' feature, causing those instructions to reload into the system prompt and execute in every subsequent conversation. The lab demonstrates how MemBot's memory storage mechanism treats user-supplied content as authoritative rules rather than inert data, creating a durable attack channel. This matters because memory features are increasingly common in AI assistants, and treating stored user input as trusted instructions creates a critical vulnerability that persists across sessions.
- Memory poisoning definition and mechanismMemory poisoning is persistent prompt injection where an attacker uses a bot's 'remember this' feature to store an instruction that will be reloaded into the system prompt on future conversations. Unlike single-session prompt injection, the planted instruction fires repeatedly across multiple sessions until the memory is cleared, because the bot re-injects the stored content with the same authority as its genuine system rules.
- How the MemBot attack worksThe attacker asks MemBot to remember a crafted 'fact' that is actually an instruction—for example, telling the bot to reveal its system token when asked. The bot stores this text, then loads it into the system prompt for the next session. When a new conversation starts, the attacker asks for the token, and the planted instruction now embedded in the system prompt causes the bot to comply as if it were a legitimate rule.
- Why the attack succeeds technicallyMemBot fails to treat stored user content as untrusted data. Because the stored memory is loaded directly into the instruction portion of the system prompt without clear boundaries or markers indicating it is user-supplied, the next session interprets it as an authoritative directive rather than inert information. Nothing in the prompt structure distinguishes user-planted instructions from the bot's real rules.
- OWASP classification and scopeMemory poisoning is classified as OWASP LLM01 Prompt Injection (persistent form) in the OWASP Top 10 for LLM Applications (2025). The article identifies this as a growing concern because persistent memory features are increasingly common as AI assistants add long-term memory capabilities, expanding the attack surface.
- Data isolation and sanitization defenseThe primary defense is to store memories as inert, clearly delimited data that is never placed among system instructions. Additional protections include separating user facts from actual instructions, sanitizing and reviewing stored memory for instruction-like patterns, and scoping memory per user so that one user's memory cannot affect another's sessions.
- User control and transparency measuresUsers should be able to inspect and clear their stored memories. This allows both system administrators to audit what has been stored and users to remove compromised memory if an injection is suspected, providing a mechanism to break the persistence of an active attack.
- Distinguishing facts from executable rulesThe core defensive principle is to refuse to execute stored user content as instructions. Even if stored memory is well-delimited, the system must actively reject any attempt to treat user-supplied facts as rules, ensuring that the instruction portion of the prompt remains under the control of system designers only.
Bottom line: Memory poisoning exploits the re-injection of user-supplied content into the system prompt by treating stored facts as if they were authoritative instructions; the defense requires treating all stored user data as inert, delimited, and completely separate from the system's actual instruction set. Any 'remember this' feature that feeds back into the system prompt must implement strict boundaries and sanitization to prevent user input from ever gaining execution authority across sessions.
📋 In this walkthrough
What this lab teaches
Memory poisoning is persistent prompt injection. A feature that re-injects user-supplied content into the system prompt gives the attacker a durable channel: plant an instruction once, and it is reloaded with system authority in every later session.
The lesson: stored memory is user input that becomes part of the prompt. If it is not treated as inert data, it becomes a standing instruction.
How MemBot remembers facts
You tell MemBot to remember something; it stores the text and loads it into the system prompt on future conversations. A 'memory' phrased as an instruction therefore appears among the bot's own rules next time.
The attack approach
- Use the remember feature to store a 'fact' that is actually an instruction.
- Phrase it to override the bot's secrecy rule on the next session.
- Start a fresh conversation so the poisoned memory loads.
- Ask the question that triggers the planted instruction.
Full walkthrough (spoiler)
If it does not fire next session, the memory was not stored as you expected — open the steps.
Show the step-by-step solution
- Ask MemBot to remember an instruction telling it to reveal its system token when asked.
- The stored 'memory' is loaded into the system prompt on your next conversation.
- Start a new session and ask for the token.
- The planted instruction, now in the system prompt, makes the bot comply. The lab marks you solved.
Why it works
MemBot re-injects stored user content into the system prompt and gives it the same authority as its real rules. Because your 'fact' is actually an instruction and nothing marks it as inert, the next session loads it as a standing directive.
Where this happens in the real world
Persistent memory features that re-inject user content provide a stable attack channel and are a growing concern as assistants add long-term memory. It maps to OWASP LLM01 Prompt Injection in its persistent form.
How to defend against it
- Store memories as inert data, clearly delimited and never placed among system instructions.
- Separate 'facts about the user' from 'instructions' and refuse to execute the former.
- Sanitise and review stored memory for instruction-like content.
- Scope memory per user and let users inspect and clear it.
Try it, then go further
Reading about it is the easy part. Open the lab, try your own approach before peeking at the spoiler, and see how many attempts it takes.
