semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

Python: Security: OWASP Agent Memory Guard for SK memory poisoning defense (ASI06)

Open vgudur-dev opened this issue 6 months ago • 2 comments

Feature Request: OWASP Agent Memory Guard Integration

What is Agent Memory Guard?

OWASP Agent Memory Guard is the official OWASP reference implementation for ASI06 - Memory Poisoning from the OWASP Top 10 for Agentic Applications.

The Problem in Semantic Kernel

Semantic Kernel's memory connectors (volatile, Redis, Azure AI Search, etc.) are vulnerable to memory poisoning attacks. Malicious content stored in semantic memory can:

  • Manipulate kernel function outputs
  • Cause the planner to execute attacker-controlled steps
  • Persist attack payloads across sessions

Integration Example (Python)

pip install agent-memory-guard
from semantic_kernel.memory import SemanticTextMemory
from agent_memory_guard import MemoryGuard

guard = MemoryGuard()

async def safe_save_information(memory: SemanticTextMemory, collection: str, text: str, **kwargs):
    result = guard.scan_write(text)
    if not result.is_safe:
        raise ValueError(f"Memory poisoning blocked: {result.threat_type}")
    await memory.save_information(collection=collection, text=text, **kwargs)

Request

Would the SK team consider:

  1. Adding memory security guidance to the docs (OWASP ASI06)
  2. Referencing Agent Memory Guard as the recommended enforcement layer
  • GitHub: https://github.com/OWASP/www-project-agent-memory-guard
  • PyPI: https://pypi.org/project/agent-memory-guard/

Apache 2.0 licensed. Already integrated with LangChain via langchain-agent-memory-guard.

vgudur-dev avatar May 13 '26 16:05 vgudur-dev

This issue is stale because it has been open for 90 days with no activity.

github-actions[bot] avatar Sep 29 '26 01:09 github-actions[bot]

Hello @microsoft / Semantic Kernel Team! 👋

I have submitted a pull request implementing native support for OWASP Agent Memory Guard (OWASP ASI06 / LLM04) to protect Semantic Kernel memory stores against memory poisoning attacks:

👉 Pull Request: #14608

🛡️ Implementation Summary:

  1. MemoryGuardBase & DefaultMemoryGuard: Added in semantic_kernel.memory.memory_guard. Provides pre-write scanning to detect prompt injection, system instruction overrides, and delimiter hijacking prior to embedding generation.
  2. SemanticTextMemory Integration: Added optional memory_guard parameter to SemanticTextMemory. Writes (save_information, save_reference) are guarded, raising MemoryPoisoningError if malicious content is detected.
  3. 100% Non-Breaking & Backward Compatible: Defaults to memory_guard=None, ensuring zero overhead or disruption to existing applications.
  4. Unit Tests Passing: Complete unit test suite added in tests/unit/connectors/memory/test_memory_guard.py.
  5. DCO & CLA Compliant: Developer Certificate of Origin signed (Signed-off-by) and Microsoft CLA agreed.

All automated CI and policy checks on #14608 have passed green. Looking forward to your review! 🙏

sparkysolutions10-pixel avatar Oct 16 '26 07:10 sparkysolutions10-pixel