Defending your Memory in Microsoft Foundry Agent Service against memory poisoning
Summary
Microsoft Foundry Agent Service utilizes memory to provide agents with continuity, enabling them to recall user preferences, summarize conversations, and retrieve context for personalized interactions. This memory system operates in four phases: extraction, consolidation, storage, and retrieval, supporting user profile, session summary, and procedural memory types. However, this capability introduces a memory poisoning risk, where attackers inject malicious or misleading information into long-term memory, influencing future agent responses or tool usage. Unlike prompt injection, memory poisoning aims for persistence, allowing harmful instructions to resurface in unrelated sessions. Microsoft proposes a "MemoryGuard" validation layer to defend against this by inspecting candidate memories before persistence, isolating memory by scope, narrowing extraction policies, and grounding official answers in trusted knowledge sources.
Key takeaway
For AI Security Engineers or AI Architects designing agentic applications, you must implement robust write-path validation for agent memory to prevent persistent memory poisoning attacks. Prioritize a hosted-container architecture to deploy a "MemoryGuard" layer, ensuring all candidate memories are inspected and validated against strict policies—including URL allow-lists and LLM classification—before persistence. This proactive defense minimizes exposure to malicious instructions, safeguarding future agent behavior and maintaining the integrity of operational workflows.
Key insights
Agent memory, while enabling continuity, creates a security boundary vulnerable to persistent poisoning, requiring write-path validation.
Principles
- Treat agent memory as a security boundary.
- Isolate memory by scope and type.
- Ground official answers in trusted knowledge.
Method
Implement a MemoryGuard fail-fast pipeline between memory extraction and persistence. This pipeline uses regex, URL allow-lists, heuristic checks, and an LLM classifier to validate candidate memories before writing them to durable storage.
In practice
- Configure "user_profile_details" as a strict extraction policy.
- Use Memory Store APIs for custom validation, not the managed tool.
- Log all MemoryGuard decisions for audit and tuning.
Topics
- Microsoft Foundry Agent Service
- Memory Poisoning
- Agent Security
- MemoryGuard
- Prompt Injection
- AI Security Architecture
- Kusto Query Language
Best for: AI Security Engineer, AI Engineer, AI Architect
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by Microsoft Foundry Blog articles.