Protecting LangChain agent memory from poisoning attacks — OWASP Agent Memory Guard (open source)

Hey LangChain community,

I wanted to share an open-source security tool I’ve been building under OWASP that directly addresses a growing threat for LangChain-based agents: memory poisoning attacks.

When your LangChain agent reads from memory (conversation history, vector stores, retrieved documents), malicious content in that memory can hijack the agent’s behavior. An attacker who can write to your agent’s memory can make your agent exfiltrate data, execute unintended actions, or bypass safety guardrails.

I built Agent Memory Guard as a Python middleware that scans memory inputs/outputs for injection patterns before they reach your LangChain agent.

Install: pip install agent-memory-guard

It detects prompt injection patterns in memory, role-hijacking attempts, data exfiltration commands embedded in retrieved content, and indirect injection via tool outputs.

This maps directly to OWASP LLM Top 10 - specifically LLM02 (Insecure Output Handling) and LLM06 (Sensitive Information Disclosure).

GitHub: GitHub - OWASP/www-project-agent-memory-guard: OWASP Foundation web repository · GitHub

PyPI: agent-memory-guard · PyPI

Would love feedback from this community - especially on edge cases you’ve seen in production LangChain deployments.