arXiv:2610.28810cs.CROct 2026

Manuscript Offprint

arXiv:2610.28810

Combining Long-Term Memory and LLMs Comes at a High Cost: From Prompt Injection to Persistent Compromise

Pedro H. Barcha Correia, Matheus Azevedo de Sá, Paulo H. Gomes de Senna, Giovanni Mandel Martignago, Victor Takashi Hayashi, Charles Christian Miers, Marcos A. Simplicio

Pedro H. Barcha Correia*, Matheus Azevedo de Sá†, Paulo H. Gomes de Senna†, Giovanni Mandel Martignago†, Victor Takashi Hayashi*, Charles Christian Miers†, and Marcos A. Simplicio Jr.*

  • {pedro.correia, victor.hayashi, msimplicio}@usp.br, Universidade de São Paulo (USP), São Paulo, Brazil

† {matheus.sa, paulo.senna, giovanni.mm1}@edu.udesc.br, charles.miers@udesc.br, Universidade do Estado de Santa Catarina (UDESC), Florianópolis, Brazil

Abstract—The widespread adoption of generative artificial intelligence in recent years has brought a parallel rise in prompt injection and jailbreak attacks. By embedding malicious instructions, these exploits manipulate language models to bypass intended behavior and operational boundaries. In traditional chatbots, such attacks are confined to a single session because state memory is not preserved across conversations. However, persistent memory features in modern conversational interfaces enable cross-session attack propagation, establishing a threat vector known as memory injection. This work explores this emerging vulnerability in leading LLM-as-a-service platforms, highlighting its real-world severity and the need for countermeasures. While existing literature focuses on violations tailored to specific platform features, we present a general threat model. We demonstrate that all NIST attack goals are collectively achievable across ChatGPT Instant 5.3, Claude Sonnet 4.6, and Gemini 3 Flash under this model. We also show that memory injections can exploit multiple attack vectors, including personal memories, projects, skills, organization instructions, and Model Context Protocol (MCP)-connected resources. Our findings reveal that all evaluated services can be manipulated to persistently spread disinformation, generate harmful content, or simulate offline unresponsiveness, even in fresh sessions. In the particular case of Claude, shared-memory features allow an attacker to compromise multiple users within an organization and also exfiltrate user prompts. To address these vulnerabilities, we derive defense mechanisms from our proposed threat model and foundational cybersecurity principles. Our analysis indicates that nearly half of these mitigations remain unimplemented across the target services. Datasets and attack artifacts are available at https://github.com/PedroBarcha/Memory-injection.

Index Terms—Cybersecurity, AI, LLM, memory injection, prompt injection, jailbreak, shared memory, attack, defense

I. INTRODUCTION

Recent advances in Artificial Intelligence (AI) have enabled its widespread deployment across diverse domains, including finance [1], education [2], and healthcare [3]. This shift is primarily driven by generative AI (GenAI), which leverages underlying large language models (LLMs) to synthesize natural language and generate multimodal content spanning text, images, video, and audio.

As observed with prior emerging technologies [4], the rapid adoption of GenAI-based systems has outpaced the establishment of regulatory policies and cybersecurity protections. This asymmetry introduces significant ethical challenges while expanding the attack surface across deployed systems. Among the various threats targeting GenAI and LLM-driven applications [5], prompt injection stands out as a primary concern. This attack vector manipulates model behavior using carefully engineered malicious inputs and is ranked by the Open Worldwide Application Security Project (OWASP) as the top risk for LLM applications [6]. According to the U.S. National Institute of Standards and Technology (NIST) [7], such attacks can compromise system availability, alter model outputs, or facilitate unauthorized access to private data.

More recently, a new variant of prompt injection has emerged, enabling malicious effects to persist across user sessions [8], [9]. Known as memory injection, this attack strategy leverages memory-related capabilities originally intended to improve output quality by retaining context relevant to the user [10]–[12]. However, long-term state retention allows prompt injections previously confined to a single session to be stored and automatically reused across subsequent interactions.

Prior research demonstrates the viability of memory injection attacks across several contexts. For instance, SpAI-ware exploits native memory features in ChatGPT to plant persistent instructions that exfiltrate user conversations across sessions [8]. Similarly, MINJA inserts malicious records into an agent's shared memory bank, misdirecting subsequent user queries (e.g., toward another patient's records) [9]. Finally, ER-MIA plants synthetic memories designed to mimic legitimate records, causing similarity-based retrieval mechanisms to fetch malicious entries and degrade overall response quality [13]. Although only SpAIware targets a production service, these three studies collectively demonstrate that memory injections can compromise both data privacy and system integrity. Nevertheless, each existing work evaluates only a single memory architecture and pursues narrow attack objectives. Furthermore, the literature lacks a general threat model for memory injection and does not systematically derive mitigations from established cybersecurity principles. To address these gaps, this work formulates the following research questions:

• RQ1: Which security attack goals can be realized against GenAI systems through memory injection?

• RQ2: Which persistent-memory features can serve as vectors for memory injection?

• RQ3: How can memory injection be systematically mitigated?

• RQ4: To what extent are these mitigations currently implemented in well-established LLM-as-a-service platforms?

This work addresses these questions through a structured analytical and empirical framework. First, we propose a general threat model for memory injection that incorporates all adversarial goals against GenAI systems outlined in the NIST AI security guidelines [7] (RQ1), namely availability breakdown, integrity violation, privacy compromise, and misuse enablement. To complement this theoretical foundation, we design and execute empirical attacks targeting various persistent-memory mechanisms (e.g., personal memories, workspace projects, custom skills, organization instructions, and MCP-connected resources) available in Anthropic Claude (Sonnet 4.6), Google Gemini (3 Flash), and OpenAI ChatGPT (Instant 5.3) (RQ2). Next, we systematically derive defensive countermeasures grounded in our threat model and established OWASP security principles [14] (RQ3). Finally, we analyze the three target services to evaluate the actual implementation status of these mitigations (RQ4).

By addressing these research questions, this work advances the understanding of memory injection, an emerging threat vector that remains largely underexplored in the literature. Our findings demonstrate that memory injections can achieve the full range of NIST-defined attack goals through multiple persistent-memory mechanisms, although some features are more vulnerable than others. Specifically, we experimentally show that persistent injections can induce disinformation, trigger harmful content generation, and simulate service unavailability across all three evaluated platforms. Regarding data privacy, Claude's shared-memory features allow an injection planted by a single organizational user account to compromise co-workers, enabling the cross-user exfiltration of sensitive prompt data. Despite the severity of these attacks, our analysis reveals that popular LLM-as-a-service solutions remain largely unprotected, frequently overlooking the mitigations identified in this study. In this context, this work aims to raise awareness of the risks surrounding memory injection and outline practical defensive controls against them 1^{1}. To support open science and facilitate further research, all evaluation prompts, model outputs, reproduction procedures, datasets, and auxiliary artifacts are publicly available at https://github.com/PedroBarcha/Memory-injection.

Outline. The remainder of this paper is organized as follows. Section II provides background on prompt injection attacks and details the implementation of memory features in popular LLM-as-a-service platforms. Section III reviews related work on memory injection vulnerabilities. Section IV formalizes our general threat model for memory injection attacks. Section V describes our experimental setup and methods, and then presents the proposed attacks and their results. Section VI analyzes the experimental findings and directly addresses our research questions. Finally, Section VII concludes the paper and highlights directions for future work.

References (41)