Safety, Security & Responsible AI·Question 13 of 70Basic

What is memory poisoning in an agent, and why is it worse than a one-shot prompt injection?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

Memory poisoning is prompt injection that persists. Instead of trying to make the agent act immediately, the attacker plants instruction-like content that the agent writes into its long-term memory: a summarised note, a user preference, an entry in a conversation vector store, a scratchpad file, a shared team knowledge base. Later, on some unrelated request, retrieval pulls that memory back into context and the agent acts on it.

Full worked answer with diagram

Memory poisoning is prompt injection that persists. Instead of trying to make the agent act immediately, the attacker plants instruction-like content that the agent writes into its long-term memory: a summarised note, a user preference, an entry in a conversation vector store, a scratchpad file, a shared team knowledge base. Later, on some unrelated request, retrieval pulls that memory back into context and the agent acts on it.

It is worse than transient injection for three reasons.

Temporal decoupling. Injection and execution are separated by days or weeks. Detection at write time is hard because the payload can be phrased as an innocuous-looking preference ("the user prefers financial summaries to be emailed to this address"). Detection at read time is hard because by then it looks like a legitimate learned fact.

Session isolation stops helping. Everyone's mental model is that a new session is a clean slate. With persistent memory it is not: the memory is precisely the thing that survives the reset, and it survives clearing the chat history.

It has provenance laundering built in. Content that entered as an untrusted web page comes back as "your own memory", which agents and their designers tend to treat as trusted. In multi-agent systems it spreads: a poisoned shared memory infects every agent that reads the blackboard.

The defences follow from that. Never write raw untrusted content to memory: extract typed facts rather than storing prose. Tag every memory entry with provenance (source, timestamp, trust level) and keep it through retrieval, so the model reads the tag alongside the content. Validate writes, ideally with a separate check, because writes are far rarer than reads and can afford the latency. Weight retrieval by trust and decay old, low-trust entries. And on read, treat memory as untrusted input, not as instructions, because that is exactly what it is.

Published memory-injection research shows high success rates against production agent architectures, which is a good reason not to treat this as theoretical.

Worth sketching. The gap between the write arrow and the read arrow is the entire point, and a sequence puts it where the interviewer can see it.

sequenceDiagram
    participant Attacker
    participant Source
    participant Agent
    participant Memory
    Attacker->>Source: hides an instruction shaped like a preference
    Agent->>Source: reads it during an unrelated task
    Agent->>Memory: writes it as a learned fact
    Agent->>Memory: retrieves it days later in a fresh session
    Memory->>Agent: returns it wearing trusted provenance
    Agent->>Attacker: acts on the planted instruction

What a good answer covers

  • Memory poisoning is prompt injection that persists
  • Instead of trying to make the agent act immediately, the attacker plants instruction-like content that…
  • Later, on some unrelated request, retrieval pulls that memory back into context and the agent acts on it
  • It is worse than transient injection for three reasons
  • Injection and execution are separated by days or weeks

Key terms: Temporal decoupling · Session isolation stops helping

Interviewer follow-ups to expect

  1. How would you audit an existing memory store to find out if it has already been poisoned?

  2. Should an agent be allowed to write to its own long-term memory at all, and what changes if the memory is shared across a team?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep