Secure memory system prevents unauthorized use in large language models

SAFE-Mem: Secure Agentic Memory with Fine-Grained Authority and Governance-Aware Retrieval

Cryptography and SecurityComputation and Language

Summary

Large language model agents use memory to remember things over time, but sometimes this memory can hold wrong or unsafe information from untrustworthy sources. The authors propose SAFE-Mem, which tags each piece of stored information with labels describing where it came from and how it can be used. When the model tries to recall information, SAFE-Mem checks these tags to ensure only allowed information influences decisions, reducing risks without blocking useful facts. This approach improves safety while keeping the models accurate and useful.

What this means in practice

  • For llm developers: Implement a memory system that carefully controls what external claims influence model decisions to improve security and maintain accuracy.
  • For enterprise ai teams: Deploy safer AI assistants that avoid unauthorized or harmful memory use by enforcing fine-grained access controls on stored knowledge.

Authors

Haoming Li, Dingyi Kang, Xu Hu, Jinxin Yang, Zhu Xu, Chenru Wang, Yi Ge, Miao Yin, Guanpeng Li, Feng Chen, Bingzhe Li

Abstract

Large language model (LLM) agents increasingly rely on persistent memory to support long-term reasoning and personalized interactions. However, information collected from external sources can introduce security risks when untrusted claims (i.e., atomic statements) are later treated as authorized preferences, policies, or permissions. Existing defenses typically rely on content-based filtering or coarse-grained provenance tracking, which either fail to prevent unauthorized memory use or block legitimate information, sacrificing memory utility. To address these limitations, we propose SAFE-Mem, a fine-grained memory governance framework that improves security while preserving legitimate memory use. First, SAFE-Mem annotates each claim with three governance labels (i.e., kind, authority, and scope) to capture its provenance and permitted use. Second, governance-aware retrieval matches query requirements with claim permissions to block unauthorized influence while retaining legitimate information. Third, a governance-enabled memory graph connects source sentences, claims, and entities to support provenance tracking and efficient retrieval. Across four LLM backbones on MPBench and LoCoMo, SAFE-Mem attains the lowest attack success among defenses that retain legitimate memory, at least 77% below the strongest of them, and the highest answer accuracy of all evaluated defenses, improving it by up to 15%. The code is available at https://github.com/LVenum/SAFE-Mem.