microsoft / microsoft/semantic-kernel

Python: [Feature] Memory validation layer to protect against memory poisoning attacks (OWASP AMG integration)

Open
#14,062 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

python triage
Dominant language
C#
Stars
28.6k
Forks
4.8k
Avg merge
14h 13m
Merged PRs (30d)
18

Description

Scenario

Semantic Kernel's memory features (TextMemoryPlugin, VolatileMemoryStore, connectors) allow agents to store and retrieve information across interactions. However, there's currently no built-in validation to prevent memory poisoning attacks — where adversarial content gets stored in memory and alters agent behavior in subsequent sessions.

This is now a documented attack class: Memory Poisoning Attacks in LLM Agents (arxiv, June 2026)

Proposal

Add an optional memory validation layer that scans entries before they're persisted to any IMemoryStore implementation. This could be implemented as:

  1. A middleware/decorator pattern for IMemoryStore
  2. A configurable validation step in the memory pipeline

There's an existing open-source solution that already supports Semantic Kernel: OWASP Agent Memory Guard

What it detects:
  • Prompt injection hidden in memory entries
  • Instruction override attempts ("ignore previous instructions...")
  • Persona/identity manipulation
  • Cross-session persistence attacks
  • Encoding-based obfuscation (base64, hex, rot13)
Integration example (Python SK):
from agent_memory_guard import MemoryGuard
from semantic_kernel.memory import SemanticTextMemory

guard = MemoryGuard()

# Validate before saving to memory
async def save_with_validation(memory: SemanticTextMemory, collection, text, id):
    result = guard.scan(text)
    if result.is_safe:
        await memory.save_information(collection, text, id)
    else:
        raise MemoryPoisoningError(f"Blocked: {result.threat_type}")
Key details:
  • pip install agent-memory-guard
  • 98.7% detection rate, <2ms latency per validation
  • OWASP Incubator project (Apache 2.0)
  • Already has integrations for CrewAI, AutoGen, LangChain, and Semantic Kernel

Benefits

  • Protects SK agents from having their behavior silently altered via poisoned memories
  • Complements existing SK security practices
  • Minimal performance impact (<2ms per memory operation)
  • Could be opt-in via configuration

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the Python memory flow through TextMemoryPlugin, SemanticTextMemory, connectors, and IMemoryStore implementations. Compare the proposed middleware or configurable pipeline approaches with the existing persistence path and the OWASP Agent Memory Guard integration. Done should mean an optional validation layer can scan entries before persistence and block detected memory-poisoning content without affecting unconfigured stores.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
ai, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.