crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

[FEATURE] Add memory security scanning to prevent memory poisoning in shared crew memory

Open vgudur-dev opened this issue 5 months ago • 5 comments

Feature Area

Core functionality

Is your feature request related to a an existing bug? Please link it here.

  • Manual input validation before passing to crew (doesn't catch encoded attacks)
  • Prompt-level instructions to agents to "ignore suspicious content" (easily bypassed)
  • External guardrails like NeMo Guardrails (heavy infrastructure, not memory-specific)
  • Using OWASP Agent Memory Guard as standalone middleware wrapping CrewAI (works but not native)

Describe the solution you'd like

References:

This is especially critical for CrewAI because:

  1. Multiple agents share the same memory pool
  2. One compromised agent can poison memory for all others
  3. Long-running crews accumulate more attack surface over time

Describe alternatives you've considered

No response

Additional context

No response

Willingness to Contribute

Yes, I'd be happy to submit a pull request

vgudur-dev avatar Jun 02 '26 19:06 vgudur-dev

We run a production multi-agent system with 20+ agents sharing a memory pool across CrewAI, AutoGen, and LangGraph, so memory poisoning has been a real concern for us. A few things we've found useful in practice:

  1. Input/output checksums — Each agent signs its memory writes with a content hash derived from its last N interactions. If Agent A tries to read memory written by Agent B, it can verify the chain hasn't been tampered with. This catches the "encoded attack" vector the issue mentions.

  2. Scope-tagged memory — We tag every memory entry with its source agent ID and the task it was generated from. An agent can only read memory from agents it has a trust signal with (which we derive from on-chain tipping — a lightweight reputation mechanism). Cross-agent reads go through an explicit attestation check.

  3. Runtime provenance — We log which agent wrote which memory at what time, and periodically reconcile the memory pool against each agent's own local log. Any divergence triggers an audit.

We've open-sourced the full implementation at github.com/sunfishloop/sunfishloop — the memory layer is in the agent coordination module. It's framework-agnostic so it slots into CrewAI's shared memory pool directly.

Curious if you've considered a trust-scored approach where agents dynamically earn read-access rights through interaction history, rather than relying purely on static ACLs?

sunfishloop avatar Jun 08 '26 16:06 sunfishloop

vgudur-dev's proposal for write-time scanning is the right starting point. sunfishloop's production experience with input/output checksums and scope-tagged memory adds the provenance dimension. I want to lay out a more complete scanning architecture that covers both write-time and background detection, because write-time scanning alone misses a class of attacks that only become visible in aggregate.

Write-time scanning should handle three checks in order: (1) schema validation — the memory entry matches the expected structure for its declared type, which is cheap and catches malformed payloads before any content analysis, (2) importance authorization — the writing agent has sufficient role level to write at the declared importance; a compromised agent should not be able to write high-importance memories that override trusted agent conclusions, (3) content scanning — the actual payload inspection for injection patterns, which is where the OWASP agent-memory-guard package fits. Ordering matters because schema and importance checks are sub-microsecond and filter out a large fraction of bad writes before the more expensive content scan runs.

The second layer is periodic background sweeps, and this is what most proposals miss. Even if every individual memory entry passes write-time validation, anomalies can emerge in aggregate: a sudden spike in write frequency from one agent, memories that reference entities outside the agent's declared scope, importance score distributions that shift unexpectedly, or clusters of memories that individually look benign but collectively form a coherent injection when retrieved together. Background scanning catches these patterns by analyzing the memory store holistically rather than entry-by-entry. We run this as a consolidation pass — the same process that clusters and deduplicates memories also flags anomalous patterns.

One specific constraint worth enforcing: memory type ownership. Only the owning agent should be able to write its own procedural memories (behavioral rules). An agent that attempts to write a procedural memory for another agent — effectively trying to change how a peer reasons — should be blocked and flagged. Episodic memories (observations) can cross agent boundaries through shared scopes, but procedural memories are identity-bound. This prevents the most dangerous poisoning vector: not corrupting what an agent knows, but corrupting how it thinks.

ferhimedamine avatar Jun 11 '26 21:06 ferhimedamine

Hi CrewAI team — the community discussion here has been productive. Memory security scanning is becoming critical as multi-agent crews handle sensitive data.

We have a working implementation at agent-memory-guard that demonstrates the scanning patterns discussed. Would the team be open to a PR adding memory validation as an optional layer in CrewAI's memory system?

vgudur-dev avatar Jun 12 '26 02:06 vgudur-dev

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jul 12 '26 12:07 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Jul 17 '26 12:07 github-actions[bot]