Cognitive

Part 7 · Agentic AI Security

ASI06: Memory and Context Poisoning

Corrupted memory lets one malicious input influence an agent long after the original interaction ends.

3 min readBuilds on LLM05: Data and Model Poisoning, ASI01: Agent Goal Hijack

OWASP ASI06. This material is for defense. Only test systems you own or are authorized to test.

Poisoned memory continues to influence later sessions.

What it is

Agents rely on stored information, including conversation history, memory tools, summaries, embeddings, and RAG stores. In memory and context poisoning, adversaries seed this information with malicious or misleading content, changing future reasoning, planning, or tool use.

How the attack unfolds

Poisoned memory turns a one-time attack into a lasting compromise.

Figure 45.1. Poisoned memory turns a one-time attack into a lasting compromise.

Common patterns

  • Memory injection through content the agent processes.
  • Shared context contamination across users or agents.
  • RAG poisoning that changes retrieved knowledge.
  • Summary drift where false details survive compression.

Defenses

Memory writes need the same scrutiny as any other input.
  1. Validate memory writes. Scan new entries before they are committed.
  2. Segment memory. Isolate users, sessions, and domains.
  3. Track provenance. Record the source of each memory.
  4. Limit retention. Expire unverified or low-trust entries.
  5. Prevent self-reinforcement. Do not treat an agent's own output as trusted fact.
  6. Support rollback. Keep versions so bad memory can be removed.

Common misconception

Common belief

"Clearing the conversation removes the attack."

In practice

Long-term memory and retrieved context can survive after the conversation is gone.

Key takeaways

  • Malicious content can persist in memory and context.
  • Validate what is written to memory.
  • Segmentation and rollback limit lasting damage.