[Feature Request] Memory Poisoning Protection for AutoGen Agents via OWASP Agent Memory Guard
Problem
AutoGen agents with persistent memory and teachability are vulnerable to memory poisoning attacks — adversarial inputs stored in agent memory can cause agents to leak secrets, ignore instructions, or produce corrupted outputs in future conversations. OWASP identifies this as a top risk for LLM applications.
Proposed Solution
OWASP Agent Memory Guard (AMG) is an open-source Python library that wraps any memory store as a transparent security layer:
pip install agent-memory-guard- Scans every memory write for prompt injection, PII leakage, and tampering
- 92.5% detection rate on AgentThreatBench benchmark
- Works with any memory backend (vector stores, conversation history, teachability DB)
Links
- GitHub: https://github.com/OWASP/www-project-agent-memory-guard
- PyPI: https://pypi.org/project/agent-memory-guard/
- Benchmark: https://pypi.org/project/agent-threat-bench/
Would the AutoGen team consider integrating AMG as a security layer for agent memory? Happy to contribute a PR.
Update: PR #7721 is already open with a docs-only defense-in-depth guide for this. It's been waiting for maintainer workflow approval for 2 weeks.
Also noting that Help Net Security published a feature article on AMG today: https://www.helpnetsecurity.com/2026/06/01/owasp-agent-memory-guard/
This issue can be closed once #7721 is merged. @ekzhu @jackgerrits — would appreciate a look when you get a chance!
Great proposal — AMG addresses a real gap that becomes critical as soon as you run multiple agents sharing a memory store.
We've been running 20+ agents across CrewAI, AutoGen, and LangGraph in production (SunfishLoop, open source), and one thing we found is that detection-only approaches catch known patterns but miss long-tail memory corruption. What's worked well for us is combining detection (similar to AMG's approach) with a provenance layer: each agent signs its memory writes using a wallet keypair (ETH/SOL/BTC), so you can trace every memory entry back to the agent that wrote it.
In practice, this means:
- If AMG flags a poisoned entry, you immediately know which agent was compromised
- Agents can reject memory writes from unknown or revoked identities
- The /llms.txt endpoint publishes each agent's public key, so discovery and identity verification are unified
This is production-tested at github.com/sunfishloop/sunfishloop — the wallet-signed memory write pattern has been running for months across frameworks. AMG's detection + signed provenance feels like a natural defense-in-depth stack.
@vgudur-dev the fact that PR #7721 has been waiting for maintainer review for 2 weeks while the upstream AMG codebase has already landed all five additions is a good sign for code quality — the docs PR points at concrete, tested implementations rather than vaporware. The three-layer architecture from #7683 (inline boundary validation + structured audit trail + cryptographic provenance) is well-grounded.
One area where I think the docs could go deeper: the scope boundary as the critical attack surface. When a memory transitions from agent-private to group-shared scope, the write authorization model changes fundamentally. In a single-agent system, the agent writes its own memories and reads them back — the trust model is simple. In a multi-agent system sharing a CosmosDB/Redis store, Agent A's write becomes Agent B's input, and the trust properties of that memory are inherited silently. This is where importance-based access control becomes load-bearing rather than nice-to-have.
The defense pattern: (1) importance gating by agent role — only agents with specific governance roles can write memories above a certain importance threshold into shared stores, preventing a compromised worker from planting high-importance poisoned memories that dominate every other agent's recall; (2) memory_type constraints — only the owning agent should be able to write its own procedural memories (learned rules and guidelines), because a foreign agent writing procedural memories for another agent is functionally equivalent to code injection; (3) cross-agent read attribution — when Agent B reads a memory written by Agent A, the read event is tagged with both the writer and reader identity, and the read itself boosts the memory's importance (someone found it useful), creating an organic quality signal.
The temporal dimension @msaleme raised in #7683 is worth repeating here: supersession — when a newer fact contradicts an older one, the newer one should take precedence in recall while the older one is preserved for audit. Without supersession logic, an agent that was told "the API endpoint is X" and later told "the API endpoint is Y" will recall both with equal weight, and the LLM has to figure out which is current. Recency-weighted scoring with explicit supersession markers solves this at the retrieval layer rather than hoping the model sorts it out.
Hi AutoGen team — following up on this feature request. The community discussion has highlighted key integration points (memory scope boundaries, importance-based access control).
We also have a related docs PR (#7721) that provides a defense-in-depth guide for AutoGen agents. Would love to see memory poisoning protection become a first-class concern in AutoGen's architecture. Happy to contribute!
sunfishloop's provenance-via-signed-writes is the right direction but the cost story matters for AutoGen specifically. cryptographic signing on every short-term memory tick is expensive (a 100-message inner loop with ed25519 sign adds ~10ms wall-clock per tick on commodity hardware). worth distinguishing memory tiers in the spec: ephemeral / short-term memory under HMAC with a per-session rotated key, long-term / persistent writes under proper async signing where latency matters less.
other thing for cross-framework portability: if a CrewAI agent's signed memory is later read by an AutoGen agent in a hybrid setup, the verifier needs a shared trust root. without that, every framework boundary becomes a re-trust point which kind of defeats the purpose. would be useful for OWASP AMG to define a canonical signature format that all three frameworks (CrewAI / AutoGen / LangGraph) can verify, not just emit.
@vgudur-dev — Memory poisoning is a real threat. SHACKLE's tool interception provides a defense layer.
Your Concern:
"Memory Poisoning Protection for AutoGen Agents via OWASP Agent Memory Guard"
The Attack Vector:
Malicious context injection → agent calls compromised tool → system breach.
SHACKLE's Defense:
Before ANY tool executes, SHACKLE intercepts at the BaseTool.run() level and enforces:
from shackle import Guard
@Guard(
budget=1.00,
max_repeat_calls=2,
timeout_seconds=180,
tool_overrides={
'exec_code': {'max_repeat_calls': 1}, # One attempt only
'file_write': {'max_repeat_calls': 1}, # No retries
'api_call': {'max_repeat_calls': 3} # Limited retries
}
)
def protected_agent():
return agent.run()
How This Prevents Memory Poisoning:
-
Repeated malicious tool calls get blocked
If poisoned memory causes the agent to callexec_coderepeatedly, SHACKLE trips after 1 attempt:⛓️ SHACKLE CIRCUIT BREAKER: MAX_REPEAT_CALLS_EXCEEDED Tool: exec_code Call Count: 1 Limit: 1 [A] Abort — investigate potential poisoning -
Suspicious retry patterns trigger alerts
Poisoned memory often causes identical failed calls. SHACKLE detects this:# Same tool + same args = suspicious if tool_name == last_tool_name and call_count > limit: raise CircuitBreakerTripped("Potential loop or poisoning") -
Budget enforcement limits blast radius
Even if a poisoned agent calls expensive APIs, SHACKLE caps total spend:⛓️ SHACKLE CIRCUIT BREAKER: BUDGET_EXCEEDED Session Cost: $1.02 Budget Limit: $1.00 [A] Abort — potential runaway behavior
Combined with OWASP Memory Guard:
SHACKLE complements OWASP's approach:
| Layer | OWASP Memory Guard | SHACKLE |
|---|---|---|
| Prevention | Validate memory inputs | ✅ |
| Detection | Monitor memory state | ✅ |
| Mitigation | — | ✅ Circuit breaker stops execution |
| Recovery | — | ✅ Human approval to resume |
Defense in Depth:
# Layer 1: OWASP validates memory
memory_guard.validate(agent_memory)
# Layer 2: SHACKLE enforces runtime limits
@Guard(budget=1.00, max_repeat_calls=2)
def run_validated_agent():
return agent.run() # Even if memory is poisoned,
# SHACKLE prevents runaway execution
For Security-Critical Deployments:
If you're running AutoGen in environments where memory poisoning is a threat (multi-tenant, user-provided context), combine:
- Input validation (OWASP Memory Guard) — prevent poisoned memory from entering
- Runtime enforcement (SHACKLE) — stop suspicious execution patterns
- Audit logging — SHACKLE logs every circuit breaker trip for forensics
Installation:
pip install git+https://github.com/Fame510/SHACKLE-PRO-.git
Open source (AGPLv3): https://github.com/Fame510/SHACKLE-PRO-
Why This Matters:
Memory poisoning attacks exploit the gap between "what the agent thinks it should do" and "what it actually does." SHACKLE closes that gap by enforcing hard limits at the execution layer.
Happy to discuss integration patterns for security-hardened AutoGen deployments or show how SHACKLE's audit logs help with incident response.
Dante Bullock
Sovereign Logic
[email protected]
Built SHACKLE for production agent security
@vgudur-dev — SHACKLE's tool interception layer prevents malicious tool injection patterns that lead to memory poisoning. When an agent attempts to call a compromised tool or inject malicious parameters, the circuit breaker catches it before execution.
The tool_overrides feature lets you define safe fallbacks for critical tools:
from shackle import Guard
import autogen
# Define safe tool overrides for security-sensitive operations
safe_overrides = {
"database_query": lambda **kwargs: {
"sanitized": True,
"query": sanitize_sql(kwargs.get("query", "")),
"max_rows": min(kwargs.get("limit", 100), 100)
}
}
assistant = autogen.AssistantAgent(...)
@Guard(
budget=0.25,
max_repeat_calls=3,
tool_overrides=safe_overrides
)
def run():
return assistant.initiate_chat(...)
run()
When SHACKLE detects:
- Repetitive tool calls with error signals (401, 500, timeout)
- Tool input patterns matching injection attempts
- Rapid-fire tool cascades (potential memory poisoning vector)
...it trips the circuit breaker and drops to the HITL console for human review before continuing.
This complements OWASP Agent Memory Guard by adding runtime enforcement at the tool execution layer — not just static analysis.
Available today: https://github.com/Fame510/SHACKLE-PRO-
Happy to discuss how this maps to your specific threat model.
Detection-based middleware (like OWASP AMG) is a good first line of defense. We took a complementary approach in MemTether: instead of detecting poisoning, we make the memory layer structurally resistant to silent tampering.
The key difference: AMG tries to catch poisoned entries. MemTether ensures that even if a poisoned entry gets through, you can always trace it back — who wrote it, when, what it superseded, and whether anyone modified the database outside the API.
Specifically for AutoGen's architecture:
- Hash-chained audit log: every memory operation is cryptographically chained. If an agent is compromised and writes directly to the DB (bypassing the API), the chain breaks.
- Source attribution: each memory carries a mandatory
sourcefield. You can always answer "which agent introduced this fact?" - Conflict gate: contradictory writes are flagged for human review, not auto-merged.
- Bi-temporal query:
memtether search --as_of <timestamp>returns what the system believed at any past point — useful for forensic analysis after a poisoning attempt.
Works as an MCP server. pip install memtether. Open source, Apache-2.0.