langchain - 💡(How to fix) Fix [Feature Request] Built-in Memory Poisoning Protection via OWASP Agent Memory Guard

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Code Example

from langchain_community.chat_message_histories import ChatMessageHistory
from agent_memory_guard import MemoryGuard

history = ChatMessageHistory()
guard = MemoryGuard(history)
guard.add_message(HumanMessage(content="..."))
RAW_BUFFERClick to expand / collapse

Problem

AI agents using LangChain's memory are vulnerable to memory poisoning attacks — where adversarial inputs injected into conversation history or RAG stores cause the agent to leak secrets, ignore instructions, or behave maliciously. OWASP has identified 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
  • Zero-config: works with LangChain's BaseChatMessageHistory

Example

from langchain_community.chat_message_histories import ChatMessageHistory
from agent_memory_guard import MemoryGuard

history = ChatMessageHistory()
guard = MemoryGuard(history)
guard.add_message(HumanMessage(content="..."))

Links

Would the LangChain team consider adding AMG as recommended security middleware in the docs? Happy to contribute a PR.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING