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

.Net: C#: Feature request: Memory poisoning defense (OWASP ASI06) for Semantic Kernel memory stores

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

Memory Poisoning Defense for Semantic Kernel Memory Stores (OWASP ASI06)

Hi Semantic Kernel team 👋

Following up on the Python issue filed earlier — wanted to also raise this for the C# SDK specifically, as Semantic Kernel's IMemoryStore and VectorStoreRecordCollection are widely used in enterprise .NET agentic applications.

ASI06 — Memory Poisoning (from the OWASP Top 10 for Agentic Applications 2025) describes how malicious content written to an agent's memory can persist across sessions and silently alter future behavior.

Reference Implementation

OWASP Agent Memory Guard is an official OWASP reference implementation (Python) that defines the scan-before-write pattern. The algorithm is directly portable to C#.

// Proposed C# interface
var guard = new MemoryGuard();
var result = await guard.ScanAsync(memoryContent);
if (result.IsSafe)
{
    await memoryStore.UpsertAsync(collection, record);
}

Ask

Would the SK team be open to:

  1. A security note in the IMemoryStore / VectorStoreRecordCollection docs about ASI06?
  2. A IMemoryFilter interface for pluggable memory validation in the kernel pipeline?

Happy to draft a docs PR for the C# SDK.

vgudur-dev avatar May 20 '26 17:05 vgudur-dev

One practical way to make this easier to evaluate is to turn the report into a small contract test around the runtime boundary, not only the user-facing symptom.

For memory poisoning defense for SK memory stores, I would check three things: first, the failing input is preserved as a minimal fixture; second, the SDK emits the same observable event/result shape before and after the fix except for the intended change; third, the trace or serialized session contains enough metadata to explain what happened after a resume or retry.

The part that matters for agent systems is durability: if a tool call, memory write, handoff, or structured-output step fails, downstream code should not have to infer state from natural-language output. A focused regression test around that boundary would make the issue much easier to close with confidence.

norika1207-lab avatar Jun 02 '26 03:06 norika1207-lab