A Layered Security Framework Against Prompt Injection in RAG-Based Chatbots
On the map: LLM safety and security → Prompt injection and agent security
Abstract (arXiv)
Prompt injection is ranked as the most critical vulnerability in large language model (LLM) deployments by the OWASP Top 10 for LLM Applications, yet existing defenses operate at isolated pipeline stages and remain incomplete. Input filters cannot inspect retrieved documents, while output monitors cannot prevent malicious payloads from reaching the model. Consequently, retrieval-augmented generation (RAG) chatbots remain vulnerable to indirect injection, where a poisoned knowledge-base document compromises every user whose query retrieves it. We present a three-layer framework that intercepts both direct and indirect prompt injection throughout the inference pipeline. Layer 1 screens user input using a rule-based pattern library and a fine-tuned semantic anomaly classifier. Layer 2 enforces a provenance-based instruction hierarchy during context assembly, preventing retrieved content from overriding operator policy. Layer 3 audits model output using a policy rule engine and semantic drift detector before delivery. A continuous audit loop aggregates structured logs and supports retraining to adapt the classifier to emerging attack patterns. The framework is model-agnostic and deploys as middleware without modifying the underlying LLM. Evaluation on 5,080 samples across GPT-4o, Llama 3, and Mistral 7B shows that the framework reduces Attack Success Rate (ASR) from 71.4% to 11.3%, outperforming the best single-layer baseline by 27.3 percentage points and a published guardrail system by 23.8 percentage points, while maintaining a 4.8% false positive rate and a median latency overhead of 61.2 ms. Ablation studies confirm that all three layers provide complementary protection and that their combined effect exceeds the sum of individual contributions.
Key facts. No citing papers in the map yet (data through 14 Oct 2026). Placed in Prompt injection and agent security, one of 12 directions in LLM safety and security. Builds on 26 of its 51 references that are in the map. First posted on arXiv 17 Jun 2026.
Builds on
26 of 51 references.
Closest ancestors · 4
Same direction, newest first
- 2024The Instruction Hierarchy: Training LLMs to Prioritize Privileged Instructions19 Apr
- 2024StruQ: Defending Against Prompt Injection with Structured Queries9 Feb
- 2023Benchmarking and Defending Against Indirect Prompt Injection Attacks on Large Language Models21 Dec
- 2023Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection23 Feb
Other references · 22
- 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,297
- 2019Sentence-BERT: Sentence Embeddings using Siamese BERT-Networkscited by 9,170
- 2023Judging LLM-as-a-Judge with MT-Bench and Chatbot Arenacited by 8,626
- 2019BERTScore: Evaluating Text Generation with BERTcited by 5,512
- 2024GPT-4o System Cardcited by 4,588
- 2020Dense Passage Retrieval for Open-Domain Question Answeringcited by 3,824
- 2023Mistral 7Bcited by 3,164
- 2023Universal and Transferable Adversarial Attacks on Aligned Language Modelscited by 3,104
- 2022Constitutional AI: Harmlessness from AI Feedbackcited by 3,050
- 2017Billion-scale similarity search with GPUscited by 2,497
- 2016MS MARCO: A Human Generated MAchine Reading COmprehension Datasetcited by 1,605
- 2023Llama Guard: LLM-based Input-Output Safeguard for Human-AI Conversationscited by 1,207
10 more
- 2022Ignore Previous Prompt: Attack Techniques For Language Modelscited by 832
- 2023Baseline Defenses for Adversarial Attacks Against Aligned Language Modelscited by 651
- 2023Jailbreaking ChatGPT via Prompt Engineering: An Empirical Studycited by 498
- 2023SmoothLLM: Defending Large Language Models Against Jailbreaking Attackscited by 469
- 2023NeMo Guardrails: A Toolkit for Controllable and Safe LLM Applications with Programmable Railscited by 365
- 2023Poisoning Language Models During Instruction Tuningcited by 269
- 2023Abusing Images and Sounds for Indirect Instruction Injection in Multi-Modal LLMscited by 124
- 2022Evaluating the Susceptibility of Pre-Trained Language Models via Handcrafted Adversarial Examplescited by 69
- 2024Improving Arabic Multi-Label Emotion Classification using Stacked Embeddings and Hybrid Loss Functioncited by 1
- 2025Do LLMs Know They Are Being Tested? Evaluation Awareness and Incentive-Sensitive Failures in GPT-OSS-20Bcited by 1
Built on by
Not cited yet.
Similar, not cited
Close in wording, no citation either way
- 2025Exploiting Web Search Tools of AI Agents for Data Exfiltration
- 2025Securing AI Agents Against Prompt Injection Attacks
- 2024Automatic and Universal Prompt Injection Attacks against Large Language Models
- 2024An Early Categorization of Prompt Injection Attacks on Large Language Models
- 2026From Prompt Injection to Web Exploitation: Revisiting Classic Vulnerabilities in LLM-Integrated Applications
- 2024Phantom: General Backdoor Attacks on Retrieval Augmented Language Generation
- 2026ClawGuard: A Runtime Security Framework for Tool-Augmented LLM Agents Against Indirect Prompt Injection
- 2026Overcoming the Retrieval Barrier: Indirect Prompt Injection in the Wild for LLM Systems