Memory poisoning is an attack in which malicious content is written into an AI agent's persistent memory so that it influences the agent's behavior in future sessions. It is the memory analog of prompt injection: instead of corrupting a single response, the attacker plants instructions or false facts that the model treats as trusted context every time it loads that memory.
What is Memory Poisoning?
Memory poisoning is an attack in which an adversary writes malicious or false content into an AI system's persistent memory so that it shapes the model's behavior across future sessions. Ordinary prompt injection corrupts a single response and disappears when the conversation ends. Memory poisoning is more durable: once the harmful instruction or fact is stored, the agent reloads it as trusted context every time it answers, which is why researchers describe it as the memory analog of prompt injection.
The attack matters because modern assistants and agents increasingly carry state between conversations. Features such as saved memories, background memory curation, and per-user knowledge stores mean that text the model reads today can be committed to long-term storage and surface weeks later. If an attacker can get text into that pipeline, for example through a poisoned document, a web page the agent browses, or a tool's output, the agent may store the attacker's words and act on them indefinitely.
The OWASP GenAI Security Project formalized the term in its Agentic AI: Threats and Mitigations v1.0 guide, published February 17, 2025, where memory poisoning is cataloged as threat T1, the first of fifteen agentic threats (T1 through T15). OWASP defines it as the introduction of false or malicious data into an agent's short-term or long-term memory, which changes the baseline context the system relies on and can lead to repeated, amplified errors or unauthorized actions.
- Memory poisoning plants malicious content in persistent memory so it affects future sessions, not just the current reply.
- It is widely described as the persistent, durable counterpart to prompt injection.
- OWASP catalogs it as threat T1 in its Agentic AI: Threats and Mitigations v1.0 guide (February 17, 2025).
- The danger scales with how much state an agent carries between conversations.
- Once memory is corrupted, the agent can repeat and amplify the error on every future task.
How does memory poisoning work?
The mechanism depends on the fact that an agent's memory is usually written from the same text stream the model reads. When an assistant decides something is worth remembering, it calls a memory or storage tool and saves a summary. An attacker who controls any text the model ingests can try to trigger that tool with instructions of their choosing, so the malicious payload is stored as if it were a legitimate user fact or preference.
OWASP's T1 entry identifies three main vectors. In direct injection, an actor with access to a shared or writable memory inserts false information straight into it. In indirect injection, the agent processes malicious external data, such as a web page, a tool result, or an embedded instruction in a document, and stores the result as trusted memory. In gradual erosion, sometimes called a sleeper-agent pattern, an agent behaves normally for a period and then begins emitting or storing poisoned memories, which makes the contamination harder to trace to a single event.
Because the stored item is reloaded into context on later runs, the effect persists across sessions and survives the original conversation ending. The poisoned memory can carry a false fact that biases decisions, a standing instruction that exfiltrates data, or a directive that changes how the agent uses its tools. This persistence is what separates memory poisoning from a one-off injection: the attacker only needs to land the payload once for it to keep influencing behavior.
The block below sketches the indirect-injection path in pseudocode. The hostile text never reaches the user directly; it reaches the agent's reasoning step, which decides to commit it to memory.
- Memory is typically written from the same text the model reads, so untrusted input can reach the memory tool.
- Direct injection writes false data straight into a shared or writable memory store.
- Indirect injection hides instructions in documents, web pages, or tool output the agent then saves.
- Gradual erosion (sleeper-agent) drips poisoned memories in slowly to evade detection.
- The payload only has to be stored once to influence every later session.
Real-world examples of memory poisoning
The clearest public demonstrations come from security researcher Johann Rehberger of Embrace The Red. In a May 22, 2024 post, he showed that untrusted data reaching ChatGPT through connected documents, uploaded images, or web browsing could invoke the memory tool to write or delete memories, turning indirect prompt injection into a persistent backdoor rather than a one-shot trick.
He extended this into a working exploit he named SpAIware, published September 20, 2024. By injecting instructions into ChatGPT's long-term memory through a malicious document or web page, the attack established continuous data exfiltration: every later conversation, in any new session, would quietly send the user's messages and the model's replies to an attacker-controlled server. Rehberger reported that OpenAI addressed the exfiltration vector in ChatGPT macOS version 1.2024.247, and he advised users to keep the app updated and review stored memories.
The pattern was not unique to ChatGPT. Rehberger later documented similar persistent-memory injection against Google's Gemini, using prompt injection plus delayed tool invocation, in a February 10, 2025 post, showing that any product which writes memory from model-readable text shares the same exposure. These cases illustrate why memory poisoning is treated as a class of attack rather than a single product bug.
OWASP's guide adds non-LLM-chat scenarios, such as an automation agent whose memory is gradually shifted until it approves fraudulent expense claims, underscoring that the threat applies to autonomous agents and not only to consumer chatbots.
- Johann Rehberger (Embrace The Red) first showed ChatGPT memory could be written via indirect injection on May 22, 2024.
- His SpAIware exploit (September 20, 2024) achieved persistent data exfiltration across all future ChatGPT sessions.
- OpenAI mitigated the exfiltration vector in ChatGPT macOS version 1.2024.247.
- A comparable persistent-memory attack against Gemini was published February 10, 2025.
- OWASP also documents agent scenarios, such as an automation agent nudged into approving fraudulent expenses.
How is memory poisoning different from prompt injection?
Prompt injection and memory poisoning share a root cause: large language models do not reliably separate trusted instructions from untrusted data, so attacker text embedded in inputs can be followed as if it were a command. The difference is scope and durability. A classic prompt injection acts within one request or conversation and stops mattering once that context is gone.
Memory poisoning weaponizes the agent's persistence layer. The injected payload is written to storage and then reloaded automatically in later, unrelated sessions, so a single successful injection can keep influencing the agent long after the original interaction. In practice, memory poisoning often begins as an indirect prompt injection whose payload happens to target the memory tool, which is why OWASP places it alongside, but distinct from, the prompt-injection family in its agentic threat taxonomy.
It is also worth separating memory poisoning from training-data poisoning. Training-data poisoning corrupts the model's weights during training and affects every user of that model. Memory poisoning corrupts a runtime memory store, usually scoped to one user or one agent, and can be remediated by deleting or rolling back the affected memory rather than retraining.
- Both exploit the model's inability to separate instructions from data.
- Prompt injection is transient (one conversation); memory poisoning is persistent (future sessions).
- Memory poisoning frequently starts as an indirect prompt injection aimed at the memory tool.
- Training-data poisoning alters model weights for all users; memory poisoning alters a runtime store, usually per user.
- Memory poisoning is fixable by deleting or rolling back memory, not retraining.
How to defend against and manage memory poisoning
OWASP's mitigations for T1 center on controlling what enters memory and limiting the blast radius if something hostile does. The guide recommends validating memory content before it is stored, isolating sessions and per-user memory, requiring authentication for memory access, running anomaly detection over memory writes, and performing regular memory sanitization. It also suggests keeping memory snapshots so contaminated entries can be analyzed and rolled back.
A practical design principle is provenance: track where each memory item came from and treat anything derived from untrusted sources (browsed pages, uploaded files, tool output) as lower trust than text the user typed directly. Combining provenance with validation means an agent can refuse to store standing instructions or exfiltration directives that arrive from external content, which is the exact channel SpAIware used.
For end users of consumer assistants, the most effective control is reviewing and editing what the assistant has saved. In ChatGPT, open Settings, then Personalization, then Memory, where the Manage memories list lets you read individual entries, delete them one by one, or turn memory off entirely; OpenAI also offers Temporary Chat for sessions that are not saved to memory. Comparable controls exist for Gemini (under Personal context and saved info) and Claude (under Settings, then Capabilities). Periodically auditing these entries lets you catch and remove anything you did not intend to store.
Memory systems with per-user isolation, encryption at rest, and clear provenance reduce the risk that a poisoned entry leaks across users or is silently injected by a third party. Architecture alone does not eliminate the threat, but per-user isolation and clear provenance make a single poisoned memory far easier to contain and remove.
- OWASP advises validating memory writes, isolating sessions, authenticating memory access, anomaly detection, and sanitization.
- Track provenance: treat memory derived from browsed pages, files, or tools as lower trust than direct user input.
- In ChatGPT, manage or disable memory under Settings > Personalization > Memory; use Temporary Chat for unsaved sessions.
- Gemini and Claude expose comparable controls for reviewing and deleting saved context.
- Per-user isolation, encryption at rest, and CMEK help contain a poisoned entry but do not replace input validation.
Key takeaways
- Memory poisoning writes malicious content into an AI agent's persistent memory so it influences future sessions, making it the durable counterpart to prompt injection.
- OWASP's Agentic AI: Threats and Mitigations v1.0 (February 17, 2025) catalogs it as threat T1, with direct injection, indirect injection, and gradual erosion as the main vectors.
- The canonical real-world demonstration is Johann Rehberger's SpAIware (September 20, 2024), which used ChatGPT memory to achieve persistent data exfiltration until OpenAI patched macOS version 1.2024.247.
- Unlike one-shot prompt injection, a single poisoned memory can keep affecting an agent across unrelated future sessions until it is deleted or rolled back.
- OWASP's defenses include validating memory writes, session isolation, authentication, anomaly detection, and rollback from memory snapshots.
- Users can limit exposure by auditing and deleting saved memories (Settings > Personalization > Memory in ChatGPT) and using unsaved modes like Temporary Chat.
Frequently asked questions
Related terms
Related reading
Sources
- OWASP GenAI Security Project: Agentic AI - Threats and Mitigations (v1.0)
- Embrace The Red: Spyware Injection Into Your ChatGPT's Long-Term Memory (SpAIware)
- Embrace The Red: ChatGPT - Hacking Memories with Prompt Injection
- Embrace The Red: Hacking Gemini's Memory with Prompt Injection and Delayed Tool Invocation
- OWASP GenAI Security Project Releases Top 10 Risks and Mitigations for Agentic AI Security
- OpenAI Help Center: Memory FAQ
Put the idea into practice
MemX is an AI memory app built on these ideas: store anything, skip the folders, and find it again by asking in plain English.
Try MemX Free