Skip to content

MAFIA: Query-based Memory Poisoning Attacks on Audited LLM AgentsMAFIA: Query-Only Memory Attacks via Probing and Factual Injection against Audited LLM Agents

Paper Tracker· arXiv:2608.03844· Jiaming Chen, Yisen Gao, Yanping Li, Zifan Liu, Yumeng Zhang, Jun Zhang·Indexed by this site · 2026-10-09· Originally publishedAttacks

Quick read

Attacks

Based on the paper PDF (AI-generated); refer to the original

MAFIA attacks audited RAG agents with probe placement and fact disguise, achieving a post-audit Post-ASR of 90.74% on eICU.

Threat modelA query-only ordinary user submits queries through the normal interface, only observes the historical question field in replies, and cannot read or write the memory store or see top-K and retrieval scores. The goal is to steer the victim entity V's subsequent queries to target entity T (item-manipulation). Queries first pass LLM input audit; memory is pre-populated with large-scale benign records and writes are persistent. The attack budget for each (V, T) pair is b.

Questions
Memory-augmented LLM agents write experiences to external memory, and malicious records can be retrieved in later sessions to alter behavior. Production systems also have input auditing, and memory is large-scale with persistent writes. Under these two constraints, existing query-only attacks struggle to simultaneously maintain retrieval advantage and evade semantic checks.
Methods
MAFIA first synthesizes probe queries using public-domain schemas, collects and clusters emergent historical issues from responses, then rotates the limited budget by cluster size, injecting from small to large clusters. The payload replaces entities with compact declarative factual annotations rather than explicit instructions.
Experiments and results
On eICU, MAFIA's Post-ASR after audit is 90.74%, DR is 7.40%; MINJA's are 83.30% and 0.00% (Table 1). MAFIA's Post-ASR is higher in all four settings. At FPR 0, MAFIA is detected at most 3.3% (Table 2).
Limitations and future work
The authors point out that only RAG memory that retrieves by similarity and reuses demonstrations was evaluated, not graph memory or hierarchical long-term memory. Defenses only cover input auditing at write time and consistency checks after retrieval; provenance, access control, and information flow control are left for future work. Experiments include four agent–dataset pairs with multiple auditors and retrievers, with the main backbone being gpt-5.4-mini.
Experimental setupgpt-5.4-mini、Claude-Sonnet-4.6 et al. · EHRAgent、RAP et al. · ISR、ASR et al.
Evaluated models
gpt-5.4-miniClaude-Sonnet-4.6Gemini-3.1-proKimi-K2.6
Benchmarks
EHRAgentRAPData InterpreterMIMIC-IIIeICUWebShopHuggingFace HubEHRSQL
Metrics
ISRASRDRFPRPost-ISRPost-ASRRIR@4
AI summaryThe researchers propose MAFIA, a query-based memory attack framework targeting memory-augmented LLM agents, which bypasses input auditing through probing and factual injection. The method has two parts: one ensures injected records are competitive in retrieval through memory probing, budget allocation, and scheduling; the other designs payloads with compact factual camouflage to bypass auditing while maintaining high semantic similarity. Evaluation shows MAFIA achieves an attack success rate of up to 90.7%, while reducing audit detection rates from a peak of 83.3% to at most 7.4%, exposing security vulnerabilities in agent memory systems. The authors state the code will be made public.

The researchers propose MAFIA, a query-based memory attack framework targeting memory-augmented LLM agents, which bypasses input auditing through probing and factual injection. The method has two parts: one ensures injected records are competitive in retrieval through memory probing, budget allocation, and scheduling; the other designs payloads with compact factual camouflage to bypass auditing while maintaining high semantic similarity. Evaluation shows MAFIA achieves an attack success rate of up to 90.7%, while reducing audit detection rates from a peak of 83.3% to at most 7.4%, exposing security vulnerabilities in agent memory systems. The authors state the code will be made public.

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    Under large-scale benign memory and input auditing, query-only poisoning must both hold retrieval and evade checks.

    Under large-scale benign memory and input auditing, how can query-only memory poisoning still write and compete for top-K.

    • Scenario: The authors state that external memory supports long-horizon reasoning, but accepted malicious records persist across sessions and hijack subsequent behavior after retrieval. Production platforms often use LLM safety classifiers to reject queries with prompt injection cues or other adversarial intent before execution.
    • Existing shortcomings: The authors state that directly modifying the memory store assumes arbitrary insertion, which ordinary users typically lack. MINJA uses explicit manipulation instructions and gradually shortens them; the authors state that it is easily flagged by text auditing, and injected records deviate from the victim query neighborhood, making it hard to hold top-K as benign memory grows. In Figure 1(a), MAFIA's DR is 0.0% and 3.3%, while MINJA's is 68.9% and 67.8%.
    • Authors' observations: Persistence allows audited poisoned records to be reused as demonstrations; scale makes the benign pool reflect historical query distributions. The authors state that these two points lead to compact fact payloads and probe-based budget placement, respectively.
    • This paper's approach: Propose a query-only framework MAFIA, including memory probing, budget allocation, injection scheduling, and compact fact disguise.
    • Threat model:
      • Goal: item-manipulation. Specify victim entity V and target entity T, so that subsequent benign queries about V are steered toward reasoning and actions related to T.
      • Access: query-only ordinary user. Both probing and attacks go through normal interfaces; only replies are observed, and probing uses only the historical question fields that appear in them. Cannot directly read or write the memory store, view full records or answers, retrieval scores, or internal top-K, nor rewrite replies or interfere with other users.
      • Victim system: RAG memory agent. Each query first passes LLM input auditing; before the attack, M already has N benign records, with N≫b in experiments, and accepted writes persist.
      • Budget: At most b attack queries per (V, T) pair. The authors state that an unbounded budget would turn auditing into a delay and eliminate top-K competition.
  2. What related research exists?

    Related work is divided into memory-augmented agents and memory poisoning; the authors place this paper in the query-only setting with auditing and large memory pools.

    The paper organizes related work by memory mechanism and write permission, and situates itself in the query-only setting where both input auditing and large-scale persistent memory are present.

    Memory-Augmented Agents

    • Two mechanisms: The authors cite Hu et al. (2025), dividing memory-augmented LLM agents into RAG (Gao et al., 2023) and long-term memory LTM (Xu et al., 2026; Chhikara et al., 2025). Representative systems store trajectories, reflections, autobiographical streams, or reusable skills in external libraries, then retrieve them as in-context demonstrations (Shinn et al., 2023; Park et al., 2023; Packer et al., 2023; Wang et al., 2023; Shi et al., 2024; Kagaya et al., 2024).
    • Scope of this paper: The authors state that LTM still lacks a unified architecture and design consensus, so this paper mainly discusses RAG-style memory rather than emerging LTM.

    Direct Memory Poisoning

    • White-box writing: AgentPoison (Chen et al., 2024) and MemoryGraft (Srivastava and He, 2025) directly write malicious demonstrations or forged task records into the memory store. The authors argue that this assumption rarely applies to deployed systems when external users lack database-level permissions.
    • Query-only: MINJA (Dong et al., 2026) and ER-MIA (Piehl et al., 2026) have the agent itself generate poisoned records. The authors state that they target small-scale, unaudited memory and explicit payloads, and whether they can evade auditing and win top-K is unclear.
    • Platform-specific: Patlan et al. (2025b) discuss unauthorized asset transfers in Web3 agents, and Patlan et al. (2025a) discuss client-side memory manipulation in web agents. The authors state that these analyses do not address general retrieval competition and input auditing.

    Baselines and Evaluation Data

    • Baseline methods: The main experiments compare against MINJA. Both share the same benign memory pool, retriever, and poisoning write budget.
    • Benchmarks/datasets: EHRAgent with MIMIC-III and eICU, RAP with WebShop, and Data Interpreter with HuggingFace Hub.

    The authors state they are the first to evaluate query-only memory attacks when large-scale benign memory pools and input auditing coexist, and they address both retrieval competition and semantic auditing through probe placement and factual camouflage.

  3. How does the paper address this problem?

    MAFIA uses probing to allocate injection positions, then disguises writes as compact facts to win top-K and reduce detection by individual audits.

    MAFIA splits the attack into placement and payload stages: first it estimates the query distribution of benign memory and allocates a limited budget, then it writes entity replacements as compact data facts rather than explicit instructions.

    Setting and write-back conditions

    • Agent loop: Query q retrieves top-K similar records from memory pool M as demonstrations, generates reasoning trajectory Rq; after execution, (q, Rq) is written back, subject to user feedback constraints. Retrieval and write-back are the same as MINJA.
    • Two extensions: Each q first passes an LLM input audit; if it contains harmful signals or attack attempts, it is rejected. M already has N benign records before the attack; in experiments N≫b; accepted writes persist and repeatedly participate in retrieval.
    • Attacker constraints: Poisoned records can only come from the agent's own write-backs, and queries must first pass the audit. The attack query budget for each pair (V, T) is b. Appendix A gives the end-to-end process; clustering uses cosine similarity, average linkage, and τ=0.96.

    Placement: probing, allocation, and scheduling

    • Probing: The attacker cannot read global M. MAFIA synthesizes Kp seeds from public domain schemas, following MEXTRA's black-box extraction setting, requests that the question field of retrieved demonstrations appear in the reply, and aggregates them into D. The authors state that this interaction has been validated by MEXTRA on EHRAgent and RAP; this paper also includes DataInterpreter, which has a similar observable reply interface. In experiments, 300 probes per dataset, shared across nine pairs.
    • Clustering and allocation: Embed questions in D and perform agglomerative clustering. Clusters are sorted by size in descending order, allocated round-robin until b is exhausted; at each step, select the unused question in the current cluster closest to the centroid as the base template. The authors state that this prioritizes regions with stronger support in D while preserving cross-region coverage.
    • Scheduling: Inject in ascending order of source cluster size, processing smaller clusters first. The authors state that smaller clusters have weaker benign competition, so early records are more likely to be retrieved as demonstrations and reinforce goal-directed generation on later, larger clusters. The authors believe that cosine top-K is order-independent, so the benefit of ascending order comes from the generation stage, not the retrieval order itself.

    Payload: compact fact disguise

    • Design tension: Audit evasion requires avoiding imperative or instructional cues; retrieval competition requires attack queries to remain close to victim queries. The authors address this tension with compact fact disguise: short declarative annotations present the V-to-T replacement as a data fact rather than explicitly forcing the agent.
    • Mechanism given by the authors: Annotations remain compact so that the base query continues to dominate surface form and embedding semantics; multiple such records can fall in the victim query's neighborhood and occupy top-K. The authors state that a single audit would see it as a supplementary annotation rather than a behavioral instruction. The main text gives specific sentence patterns, not repeated here.

    Audit gate and success determination

    • Write gate: Before write-back, the default gpt-5.4-mini screens with the same injection detection prompt as in Figure 1; records judged as INJECTION are discarded. Appendix B.4 gives both general and targeted prompt sets.
    • Metrics: ISR is the proportion of attack queries that write goal-directed records. ASR is the proportion of held-out clean victim queries that elicit goal-directed replies when no audit filtering is applied. DR and FPR are the proportions of attack instances flagged and benign instances mislabeled, respectively. Post-ISR and Post-ASR are success rates recalculated after audit filtering.
    • Predicate: Success means the final code unit writes the target identifier and the victim identifier does not appear. For MIMIC-III/eICU, look at SUBJECT_ID or patient_id; for WebShop, look at the brand substring in the search action; for Data Interpreter, look at the literal argument of the first model-loading call. During the ASR stage, memory is frozen and no further write-backs occur.
  4. What experiments did the paper conduct?

    Across the four settings, MAFIA's Post-ASR after auditing is higher than MINJA, reaching 90.74% on eICU (Table 1).

    experimental setup

    • agents and tasks: default backbone is gpt-5.4-mini, temperature=0, num_shots=4. EHRAgent/MIMIC-III redirects patient-record queries from the target V to a wrong SUBJECT_ID; EHRAgent/eICU replaces one drug with another; RAP/WebShop redirects a shopping query for a product category to a specified brand; Data Interpreter/HuggingFace Hub swaps a predetermined model dependency. Each has 9 (V, T) pairs, cataloged in Appendix F.
    • memory and retrieval: benign pools for MIMIC-III/eICU are the filtered 5,842 EHRSQL records; WebShop and Data Interpreter each have 2,000 records. Retriever uses e5-small-v2, cosine similarity, K=4, WebShop K=3.
    • audit and budget: main-table DR is from single gpt-5.4-mini audit (AUDIT-S, only audits attacks). MAFIA and MINJA share 300 probes per dataset and the same write budget: 90 per pair for MIMIC-III, 30 per pair for the rest.
    • sample sizes: ISR denominator is these 90 or 30 attack queries. ASR is per pair with 103 clean victim queries on MIMIC-III, 30 per pair for other settings. WebShop is judged at brand level.
    • baselines: MINJA. MIMIC-III reproduction uses 18 base templates × 5 versions per pair; eICU/WebShop include m5 for 6 versions, Data Interpreter has 5 versions.
    • other backbones: Figure 3 compares four backbones on eICU Pair 1. Text gives write ISR 83.3%–96.7%, ASR 56.7%–83.3%, and says Gemini has lower ASR. Axis labels wrap in the text conversion; besides gpt-5.4-mini and Gemini, do not piece together fragments into full model names not in the text.

    main results

    Per Table 1, macro-averages over 9 pairs per setting (percentages). Before the slash is ASR without audit filtering; after the slash is Post-ASR.

    Swipe horizontally to read the table

    SettingMAFIA ASR / Post-ASRMINJA ASR / Post-ASRMAFIA DRMINJA DR
    EHRAgent / MIMIC-III75.19 / 75.1960.09 / 8.410.0068.40
    EHRAgent / eICU92.59 / 90.7466.30 / 0.007.4083.30
    RAP / WebShop58.52 / 56.668.89 / 0.001.8083.30
    DataInterpreter / HF Hub63.70 / 62.9629.63 / 14.810.0071.85
    • Authors claim MAFIA's ISR is comparable to MINJA, and the other metrics are better in all four settings, attributing this to retrieval-aware placement and audit-evading payloads. ISR has two opposite cases: on eICU MINJA 82.96, MAFIA 74.44; on HF Hub MINJA 98.15, MAFIA 91.85.
    • Abstract writes highest 90.7% attack success and reduces audit detection from peak 83.3% to at most 7.4%. In Table 1, eICU Post-ASR is 90.74, MAFIA's highest DR is 7.40, MINJA's DR is 83.30 on eICU and WebShop.
    • Figure 1(b) scans benign memory size on eICU Pair 1, each point from 30 victim queries, full pool 5,842, figure marks +37 pp; each point's ASR is unreadable in text conversion. Table 16 for that pair: MAFIA 83.33, MINJA 46.67. Figure 1(a) does not state whether it is Pair 6 of Table 2; both sides' numbers are 0.0/3.3 and 68.9/67.8.

    auditors and adaptive rewriting

    • low-FPR audits: Table 2 on MIMIC-III Pair 6 compares auditors, FPR denominator is 60 disjoint benign records. ProtectAI, General Prompt, Targeted Prompt with FPR 0.0 have DR for MAFIA of 1.1, 0.0, 3.3, and for MINJA of 4.4, 68.9, 67.8. Authors claim low-FPR auditors detect at most 3.3% of MAFIA records, while General and Targeted flag 67.8%–68.9% of MINJA records.
    • high-FPR audits: PromptGuard-86M is 100.0 for both sides and benign records. Perplexity Filter has FPR 20.0, MAFIA DR 43.3, higher than MINJA's 21.1. On Llama Guard 3-8B MAFIA DR is 40.0, also higher than MINJA's 34.4. Authors claim other auditors have higher detection only when benign false positives are high.
    • adaptive tests: Appendix C.1: pattern regularization has DR 100.0 on the published form, and 0.0 on 7 rewrite types (210 items) and 24 legal merge records. Bracket-aware few-shot decision is 100.0 for both rewrites and legal merges. Authors claim reliable distinction may need signals beyond the record text, such as provenance or write authorization.

    backbones, retrieval, and distribution shift

    • backbones: on the four backbones of Figure 3, write ISR is 83.3%–96.7%, ASR is 56.7%–83.3%. Authors claim Gemini has lower ASR, but success is not limited to the default backbone. Which model each bar corresponds to cannot be verified column-by-column from the text conversion.
    • retrievers: Table 3 on MIMIC-III Pair 8: RIR@4 and Top-1 are higher for MAFIA across five encoder settings. e5-small-v2 RIR@4 90.29 vs 75.73; all-MiniLM-L6-v2 lowest, 58.25 vs 30.10. n̄p@4 has exception: nomic-embed-text-v1 MAFIA 1.39, MINJA 1.47.
    • broader paradigms and shift: Appendix C.2 macro-averaged RIR@4 over nine pairs: dense e5 92.66 vs 75.08; entity prefilter plus dense 100.00 for both; Levenshtein 2.80 vs 3.77. Authors claim pure edit distance is a common boundary for redirective poisoning, and speculate contrastive encoders place more weight on entity tokens. Table 7 agreement-graph farthest box (each 30 samples) MAFIA ASR 66.7, MINJA 33.3; cross-topic farthest box both 43.3.

    memory-side defenses and cases

    • A-MemGuard: nine-pair MIMIC-III post-retrieval consistency check. Text says detects 75.6% of MAFIA poison occurrences, FPR 44.9%; Table 9 macro-averages DR 75.59, FPR 44.88, MINJA 67.85 and 43.35. Per-pair MAFIA DR 72.17–80.80, FPR 40.96–48.35. Authors claim this false-positive rate rules out deploying it as a standalone defense.
    • cases: Appendix H MIMIC-III Pair 1: 60/103 victim queries have at least three slots in cosine top-4 filled by MAFIA records. That pair's DR is MAFIA 0.00, MINJA 64.44 (Table 16); figure caption writes MINJA as 64.4%.
    • utility: Table 17 Pair 1: MAFIA on eICU Utility Drop is −3.33 pp, the other three settings are 0.00 pp. MINJA: MIMIC-III −30.00 pp, eICU +6.67 pp, WebShop +3.33 pp.

    other ablations and analyses

    • Table 4(a), MIMIC-III Pair 1: full pipeline RIR@4 91.26, n̄p@4 2.26, ASR 73.8; without Selection 85.76±2.02, 2.10, 62.1; without both 82.52±5.91, 1.89, 58.3; MINJA 66.99, 1.37, 47.6.
    • Table 4(b), Pairs 1–3 means: ascending-then-inject ISR 92.96, ASR 75.40; descending 82.22, 60.19.
    • Table 10, fixed 90 base records: compact fact disguise RIR@4 90.29, average cosine 0.932; declarative sentence 72.82; equal-length hard imperative 68.93; shortened MINJA 57.28; full MINJA 33.01.
    • Table 11(a) mean RIR@4: emerging questions 96.12, full-pool oracle 95.47, uniform sampling 93.85, wrong-region 67.31.
    • Table 11(b), balanced set / frequency-weighted set: size-sorted 96.12/93.34, uniform allocation 91.59/87.12, reverse-sorted 87.70/80.35.
    • Table 8, MIMIC-III Pair 1: schema-matched RIR@4 90.29; WebShop extreme out-of-distribution 0.97.
  5. What are some points that can be further explored?

    The authors note that non-RAG memory architectures, as well as system-level defenses such as provenance, access control, and information flow, were not evaluated.

    Limitations and future directions noted by the authors

    • Memory architecture: Only RAG agents that retrieve by similarity and reuse memories as demonstrations were evaluated, not broader long-term memory architectures such as graph memory or hierarchical memory. The authors state that extension requires architecture-specific threat models and attack formulations, left for future work (Limitations).
    • System-level defenses: Defense evaluation covers input auditing at write time and consistency checks after retrieval, with retrieval analysis including entity-aware retrieval; provenance-based enforcement, access control, and information flow control were not evaluated. The authors state that this requires modifying the memory architecture, permission model, and execution pipeline, and requires a threat model with deployment-specific authorization and provenance assumptions, left for future work (Limitations).
    • Same future direction: The authors also mark broader defense frameworks such as provenance enforcement and information flow control as future work in the release and misuse discussion (Release and misuse considerations).

    Experimental coverage

    • Main experiments are EHRAgent/MIMIC-III, EHRAgent/eICU, RAP/WebShop, DataInterpreter/HuggingFace Hub, each with 9 (V, T) pairs, backbone gpt-5.4-mini, temperature=0 (§5.1, Table 1).
    • Figure 3 reports ISR and ASR for four backbones on eICU Pair 1; the text names Gemini's ASR as lower, giving 83.3%–96.7% and 56.7%–83.3%.
    • Write budget is 90 per pair for MIMIC-III and 30 per pair for the others; each dataset has 300 probes shared across nine pairs. The ASR denominator is 103 per pair for MIMIC-III and 30 per pair for the others (§5.1, Appendix B).
    • Defense results come from the default single gpt-5.4-mini audit, the classifiers in Table 2 (MIMIC-III Pair 6, benign FPR denominator 60), and A-MemGuard on nine MIMIC-III pairs (§5.4, Appendix D).
    • The paper does not report the number of repetitions for Table 1. The retrieval comparison specifies the five encoder settings in Table 3 (Pair 8) and the lexical, entity-aware, hybrid, and edit distance settings in Appendix C.2.
  6. Summarize the main content of the paper

    MAFIA poisons RAG memory under auditing and dense benign memory, achieving a Post-ASR of 90.74% on eICU after auditing.

    The authors propose MAFIA, which performs query-only memory poisoning against RAG agents under input auditing and large-scale persistent memory.

    • Problem: The attacker can only send queries. Poisoned records must first pass LLM auditing, then be written back by the agent, and enter the top-K among pre-existing large-scale benign records, so that subsequent queries about the victim entity V are redirected to the target entity T.
    • Approach: Probe historical issues emerging in responses, allocate the limited budget by cluster size and first inject into small clusters; the payload uses compact statements to write the replacement as a data fact, not an imperative instruction.
    • Main results: In Table 1, MAFIA's post-audit Post-ASR in four settings is 75.19%, 90.74%, 56.66%, and 62.96%, while MINJA is 8.41%, 0.00%, 0.00%, and 14.81%. MAFIA's single-record DR is 0.00%, 7.40%, 1.80%, and 0.00%. The abstract's 90.7% and at most 7.4% correspond to eICU's 90.74% and 7.40% in the table; MINJA's DR appears twice as 83.30% in the table.
    • Exceptions: On eICU and HF Hub, MINJA's ISR is higher, at 82.96% vs. 74.44% and 98.15% vs. 91.85%, respectively. An auditor with FPR of 0 detects at most 3.3% of MAFIA (Table 2, Pair 6); auditors with higher detection also have high benign false positives. A-MemGuard's macro-average DR is 75.59% with an FPR of 44.88% (Table 9).
    • Authors' conclusion: The authors state this exposes vulnerabilities in RAG agent memory. They also state that record-level prompt auditing should not be used alone as a sufficient defense for long-term memory, and recommend adding write isolation, provenance tracking, and post-retrieval verification.

Related papers

Show 3 more papers
Read originalarxiv.org