ISSTA 2026
Sun 4 - Fri 9 October 2026 Oakland, California, United States
co-located with SPLASH/ISSTA 2026

LLM-based systems are increasingly incorporating long-term memory to improve cross-session continuity and output consistency. However, the persistence of long-term memory may introduce additional risks in security-sensitive code generation: once insecure coding preferences are stored, they may silently and persistently influence security-critical choices in subsequent generations. In this study, we conduct the first systematic empirical study to evaluate the impact of insecure coding preferences stored in long-term memory on the security of LLM-based code generation. We study two widely used commercial LLMs (i.e., ChatGPT and Gemini) and examine the impact of long-term memory from multiple perspectives. Our results show that insecure coding preferences stored in long-term memory significantly increase the risk of generating vulnerable code by 11.3%–13.8%. Moreover, they reduce the likelihood that models proactively issue security warnings when producing vulnerable code, leading to a 5.4–14.5 percentage-point decrease. Further analysis reveals that these insecure memory entries are difficult to overwrite through normal interactions and can broadly influence model outputs even when prompts are phrased differently. Finally, we evaluate a mitigation strategy based on explicit security requirements, which reduces vulnerability rates by 19.7%–33.6% but may incur a functional performance drop of up to 15.9%. Based on these findings, we provide actionable suggestions to improve the security of long-term memory in LLM-based code generation.