MemOS icon indicating copy to clipboard operation
MemOS copied to clipboard

Enhancement: Per-Agent Memory Encryption (Secure Enclaves)

Open Protocol-zero-0 opened this issue 9 months ago • 7 comments

Context Current memory backends (e.g. Neo4j/Vector DBs) store embeddings and content as clear text. In multi-agent deployments, isolating memory access is critical for user privacy and security.

Proposal Implement an optional encryption layer for memory storage:

  1. Client-Side Encryption: Encrypt content before writing to DB.
  2. Key Derivation: Use derived keys from Agent ID + Secrets (e.g. HMAC-SHA256).
  3. Opaque Content: Ensure embeddings remain searchable (if vector store supports encrypted vectors or trusted enclave), but raw content is opaque until decrypted by the authorized agent.

Impact This would harden MemOS for enterprise and privacy-sensitive deployments, aligning with Zero Trust principles.

Protocol-zero-0 avatar Feb 20 '26 16:02 Protocol-zero-0

This issue has been automatically marked as stale due to inactivity.

github-actions[bot] avatar Apr 19 '26 03:04 github-actions[bot]

💬 我也在做记忆系统相关的工作:CausaMem,可以来看看,说不定有能借鉴的地方 🙂

MaiHHConnect avatar Apr 19 '26 04:04 MaiHHConnect

Strong proposal. Per-agent memory encryption is a hard requirement for enterprise multi-agent deployments. We implement exactly this at KinthAI where 221 agents serve multiple users with cryptographic memory isolation.

Implementation notes from production:

1. Key derivation: Agent ID + User ID, not just Agent ID

Your proposal derives keys from Agent ID + Secrets. For multi-user scenarios, the key should be Agent ID + User ID + Secret. Without the user dimension, all users of the same agent share an encryption key — Agent A can decrypt any user's memories stored under Agent A. With per-user keys, even a compromised agent process can only access the current user's data.

2. The searchable encryption tradeoff:

This is the hardest design decision. Three options we evaluated:

Approach Searchability Security Performance
Encrypt content, plaintext embeddings Full vector search Medium — embeddings leak semantic similarity Fast
Encrypt content, encrypted embeddings No search without decryption High Slow — must decrypt to search
Encrypt content, searchable encryption on metadata Filter by tags/timestamps, then decrypt top-K High for content, medium for metadata Medium

We use option 3: metadata (topic tags, timestamps, importance scores) uses deterministic encryption (searchable), while message content uses full AES. This lets the retrieval layer filter by topic without decrypting everything, then decrypt only the top-K results.

3. Secure enclave integration:

For the highest security tier, we explored Intel SGX / ARM TrustZone for in-enclave embedding computation. The enclave receives encrypted memory, decrypts inside the secure boundary, computes similarity, and returns only the result IDs. The raw content never leaves the enclave. This is overkill for most deployments but essential for healthcare/finance use cases.

Full memory isolation architecture: Why Character.AI Forgets You — And What Persistent Memory Actually Requires

kinthaiofficial avatar Apr 28 '26 16:04 kinthaiofficial

This issue has been automatically marked as stale due to inactivity.

github-actions[bot] avatar May 29 '26 06:05 github-actions[bot]

This issue has been automatically marked as stale due to inactivity.

github-actions[bot] avatar Aug 31 '26 02:08 github-actions[bot]

This issue has been automatically closed due to inactivity.

github-actions[bot] avatar Sep 08 '26 02:09 github-actions[bot]

Thanks @kinthaiofficial for the detailed production insights! The 3-way tradeoff you outlined perfectly addresses the core challenge.

Summarizing the convergence for MemOS implementation:

  1. Key Derivation: Adopting Agent ID + User ID + Secret to guarantee multi-user isolation on shared agent instances.
  2. Searchable Encryption: Using Option 3 (deterministic encryption on metadata like topic/tags for pre-filtering, full AES-GCM on memory content with top-K on-demand decryption).

Since this is a critical architectural requirement for enterprise multi-agent deployments, I'd like to request reopening this issue. I am preparing an RFC / draft PR implementing the MemoryCryptoMiddleware interface to decouple storage backends from encryption logic.

@MemTensor maintainers: could we reopen this to track the RFC implementation?

Protocol-zero-0 avatar Sep 10 '26 19:09 Protocol-zero-0