Context-Aware Prompt Injection Detection via Small Language Models in RAG Pipelines: nokast-secureRAG
On the map: Retrieval-augmented generation → Privacy and security of RAG
also in 1 more
Abstract (arXiv)
Local Retrieval-Augmented Generation (RAG) systems are vulnerable to indirect prompt injection and retrieval poisoning, where malicious instructions in retrieved content are mistaken for trusted input. We present nokast-secureRAG, a roughly 0.5B-parameter small language model that acts as a semantic firewall between retrieval and generation. It jointly evaluates the user query and retrieved context, classifying the pair as safe, suspicious, or malicious. The model is trained using a teacher-judge-student pipeline: a 35B teacher generates 5,233 examples across four attack families, and an independent 120B judge re-labels them, achieving 95.0% agreement before student fine-tuning. On a held-out in-distribution test set, the model achieves 0.994 detection recall at a 0.026 false-positive rate and a 0.006 attack-success-rate proxy, outperforming a regex baseline, a public prompt-injection classifier, Llama Guard 3 1B, and its untuned version. Prompt-Guard-86M reaches 0.900 recall but has a 0.690 false-positive rate. On a judgment-flip test, where the same sentence is benign or malicious depending on context, the model correctly classifies both cases 75% of the time, outperforming the compared baselines. Ablations indicate that retrieved context carries the main attack signal, while query-context consistency reduces false positives. Single-request latency is 293-404 ms, above the target of 100 ms, while amortized throughput latency is 37 ms under batching. On the external PoisonedRAG benchmark, recall falls to near zero, indicating that fluent fact-poisoning attacks lie outside the detector's instruction-consistency threat model. We report this limitation alongside the in-distribution results. The model, data-generation pipeline, and evaluation harness are released open source.
Key facts. No citing papers in the map yet (data through 24 Nov 2026). Placed in Privacy and security of RAG, one of 15 directions in Retrieval-augmented generation. Builds on 20 of its 27 references that are in the map. Submitted 20 Oct 2026.
Builds on
20 of 27 references.
Closest ancestors · 3
Same direction, newest first
- 2026Hidden-in-Plain-Text: A Benchmark for Social-Web Indirect Prompt Injection in RAG16 Jan
- 2025Benchmarking Poisoning Attacks against Retrieval-Augmented Generation24 May
- 2025SafeRAG: Benchmarking Security in Retrieval-Augmented Generation of Large Language Model28 Jan
Other references · 17
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,963
- 2015Distilling the Knowledge in a Neural Networkcited by 10,967
- 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,845
- 2023Universal and Transferable Adversarial Attacks on Aligned Language Modelscited by 3,374
- 2023Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injectioncited by 1,638
- 2023Llama Guard: LLM-based Input-Output Safeguard for Human-AI Conversationscited by 1,337
- 2022Ignore Previous Prompt: Attack Techniques For Language Modelscited by 889
- 2019Universal Adversarial Triggers for Attacking and Analyzing NLPcited by 734
- 2023Prompt Injection attack against LLM-integrated Applicationscited by 638
- 2024AgentPoison: Red-teaming LLM Agents via Poisoning Memory or Knowledge Basescited by 488
- 2023Formalizing and Benchmarking Prompt Injection Attacks and Defensescited by 415
- 2023NeMo Guardrails: A Toolkit for Controllable and Safe LLM Applications with Programmable Railscited by 397
5 more
- 2023Benchmarking and Defending Against Indirect Prompt Injection Attacks on Large Language Modelscited by 295
- 2026Overcoming the Retrieval Barrier: Indirect Prompt Injection in the Wild for LLM Systemscited by 26
- 2026Indirect Prompt Injection in the Wild: An Empirical Study of Prevalence, Techniques, and Objectivescited by 13
- 2026Evaluating System One Models for Agent Security Decisions: Reliability, Calibration, and Selective Automationcited by 12
- 2025RAG Makes Guardrails Unsafe? Investigating Robustness of Guardrails under RAG-style Contextscited by 6
Built on by
Not cited yet.
Similar, not cited
Close in wording, no citation either way
- 2026A Layered Security Framework Against Prompt Injection in RAG-Based Chatbots
- 2026RAG-PIBench: A Leakage-Aware Benchmark for Prompt-Injection Detection in Trustworthy RAG Systems
- 2024Backdoored Retrievers for Prompt Injection Attacks on Retrieval Augmented Generation of Large Language Models
- 2025RAGPart & RAGMask: Retrieval-Stage Defenses Against Corpus Poisoning in Retrieval-Augmented Generation
- 2026Retrieved But Not Reliable: A Survey on Attacks, and Defenses in Retrieval-Augmented Generation
- 2024Data Extraction Attacks in Retrieval-Augmented Generation via Backdoors
- 2025Secure Retrieval-Augmented Generation against Poisoning Attacks
- 2026SD-RAG: A Prompt-Injection-Resilient Framework for Selective Disclosure in Retrieval-Augmented Generation