ShadowMem: Defending against Long-Horizon Threats to LLM Agents via Shadow Memory
Safeguarding LLM Agents against Long-Horizon Threats via Shadow Memory
The paper proposes the ShadowMem defense framework, addressing attacks that pursue malicious goals through long-horizon interactions among the user, agent, and environment—goals that are difficult to achieve in single-turn interactions. Inspired by the shadow stack abstraction in systems security, the framework maintains a security-focused agent memory that distills and retains safety-critical context throughout the execution trajectory, and proactively assesses the risk of a pending action before it is executed. The authors report that across multiple long-horizon threats, ShadowMem's detection precision substantially outperforms existing defenses, achieves early detection for most attacks, and incurs negligible additional overhead on agent utility; the authors state this is the first framework to detect and mitigate long-horizon threats via agent memory. Code is open-sourced at https://github.com/ZJUWYH/ShadowMem。