Proceedings

BERM: Low-Overhead Prompt-Injection Detection via In-Situ Benign Representation Modeling

Download BibTeX Cite

Proceedings of the Thirty-Fifth International Joint Conference on Artificial Intelligence. Main Track. Pages 599-607.

https://doi.org/10.24963/ijcai.2026/68

Abstract

Real-world deployment of large language models (LLMs) necessitates a robust and low-latency approach to detect prompt injections; existing low-overhead methods fail to simultaneously boost robustness and reduce latency. Current defenses for prompt injection either rely on brittle heuristics or invoke costly auxiliary models, imposing a significant runtime burden. We introduce BERM, a lightweight framework that performs in-situ detection by modeling a host LLM’s internal representations extracted during prefill, adding negligible overhead. Our approach trains a lightweight classifier atop the LLM by learning a compact manifold of benign representations via joint contrastive learning to maximize the separation from malicious representations. At inference, this pre-trained classifier enables in-situ detection without invoking auxiliary guard models. On a diverse landscape of prompt injection attacks, our framework establishes a new state-of-the-art, achieving an F1-score 5.2 percentage points (pp) higher than the best prior work. Critically, BERM achieves this while being over 12x faster, reducing inference overhead to near-zero.

  1. [Blueteam AI, 2024] Blueteam AI. fmops/distilbert- prompt-injection. https://huggingface.co/fmops/ distilbert-prompt-injection, 2024. Link
  2. [Chen et al., 2020] Ting Chen, Simon Kornblith, Moham- mad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. In Pro- ceedings of the 37th International Conference on Machine Learning, pages 1597-1607. PMLR, 2020.
  3. [Chen et al., 2025] Sizhe Chen, Julien Piet, Chawin Sitawarin, and David Wagner. StruQ: Defending against prompt injection with structured queries. In 34th USENIX Security Symposium (USENIX Security 25), pages 2383-2400, Seattle, WA, August 2025. USENIX Association. [Deepset, 2024] Deepset. Deepset prompt injection dataset. https://huggingface.co/datasets/deepset/ prompt-injections, 2024. Link
  4. [Dubey et al., 2024] Abhimanyu Dubey, Abhinav Jauhri, Abhinav Pandey, Abhishek Kadian, Ahmad Al-Dahle, Aiesha Letman, Akhil Mathur, Alan Schelten, Amy Yang, Angela Fan, et al. The llama 3 herd of models. arXiv e-prints, pages arXiv-2407, 2024.
  5. [Ethayarajh, 2019] Kawin Ethayarajh. How contextual are contextualized word representations? Comparing the ge- ometry of BERT, ELMo, and GPT-2 embeddings. In Proceedings of the 2019 Conference on Empirical Meth- ods in Natural Language Processing and the 9th Inter- national Joint Conference on Natural Language Process- ing (EMNLP-IJCNLP), pages 55-65, Hong Kong, China, November 2019. Association for Computational Linguis- tics.
  6. [Gao et al., 2021] Tianyu Gao, Xingcheng Yao, and Danqi Chen. SimCSE: Simple contrastive learning of sentence embeddings. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 6894-6910, Online and Punta Cana, Dominican Re- public, November 2021. Association for Computational Linguistics.
  7. [Greshake et al., 2023] Kai Greshake, Sahar Abdelnabi, Shailesh Mishra, Christoph Endres, Thorsten Holz, and Mario Fritz. More than you've asked for: A com- prehensive analysis of novel prompt injection threats to application-integrated large language models. arXiv preprint arXiv:2302.12173, 27, 2023.
  8. [He et al., 2021] Pengcheng He, Xiaodong Liu, Jianfeng Gao, and Weizhu Chen. Deberta: Decoding-enhanced bert with disentangled attention. In International Conference on Learning Representations, 2021. [Hendrycks et al., 2019] Dan Hendrycks, Mantas Mazeika, and Thomas Dietterich. Deep anomaly detection with out- lier exposure. Proceedings of the International Conference on Learning Representations, 2019.
  9. [Hendrycks et al., 2020] Dan Hendrycks, Xiaoyuan Liu, Eric Wallace, Adam Dziedzic, Rishabh Krishnan, and Dawn Song. Pretrained transformers improve out-of- distribution robustness. arXiv preprint arXiv:2004.06100, 2020.
  10. [Jayavibhavnk, 2024] Jayavibhavnk. Prompt injection safety. https://huggingface.co/datasets/jayavibhav/ prompt-injection-safety, 2024. Link
  11. [Jiang et al., 2023] Albert Qiaochu Jiang, Alexandre Sablay- rolles, Arthur Mensch, Chris Bamford, Devendra Singh Chaplot, Diego de las Casas, Florian Bressand, Gianna Lengyel, Guillaume Lample, Lucile Saulnier, Lélio Renard Lavaud, Marie-Anne Lachaux, Pierre Stock, Teven Le Scao, Thibaut Lavril, Thomas Wang, Tim- othée Lacroix, and William El Sayed. Mistral 7B, 2023. arXiv: 2310.06825.
  12. [Li et al., 2025] Hao Li, Xiaogeng Liu, Ning Zhang, and Chaowei Xiao. PIGuard: Prompt injection guardrail via mitigating overdefense for free. In Proceedings of the 63rd Annual Meeting of the Association for Computational Lin- guistics (ACL 2025), pages 30420-30437, Vienna, Aus- tria, 2025. Association for Computational Linguistics.
  13. [Liu et al., 2024] Xiaogeng Liu, Zhiyuan Yu, Yizhe Zhang, Ning Zhang, and Chaowei Xiao. Automatic and univer- sal prompt injection attacks against large language models. arXiv preprint arXiv:2403.04957, 2024.
  14. [Meta AI, 2024] Meta AI. Introducing Llama 3.1: Our Most Capable Models to Date. Blog post, July 2024. Ac- cessed 29 Jun 2026. [Meta, 2024] Meta. Promptguard: Prompt in- jection guardrail. https://www.llama.com/docs/ model-cards-and-prompt-formats/prompt-guard/, 2024. Link
  15. [OWASP, 2023] Top OWASP. Owasp top 10 for large lan- guage model applications, 2023.
  16. [Perez and Ribeiro, 2022] Fábio Perez and Ian Ribeiro. Ig- nore previous prompt: Attack techniques for language models. arXiv preprint arXiv:2211.09527, 2022.
  17. [Phute et al., 2024] Mansi Phute, Alec Helbling, Matthew Hull, ShengYun Peng, Sebastian Szyller, Cory Cornelius, and Duen Horng Chau. Llm self defense: By self exami- nation, llms know they are being tricked, 2024.
  18. [Piet et al., 2024] Julien Piet, Maha Alrashed, Chawin Sitawarin, Sizhe Chen, Zeming Wei, Elizabeth Sun, Basel Alomair, and David Wagner. Jatmo: Prompt injection de- fense by task-specific finetuning. In European Sympo- sium on Research in Computer Security, pages 105-124. Springer, 2024. [
  19. [ProtectAI.com., 2024] ProtectAI.com. Fine- tuned deberta-v3-base for prompt injection detection. https://huggingface.co/ProtectAI/ deberta-v3-base-prompt-injection-v2, 2024. Link
  20. [Reimers and Gurevych, 2019] Nils Reimers and Iryna Gurevych. Sentence-BERT: Sentence embeddings using Siamese BERT-networks. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pages 3982-3992, Hong Kong, China, November 2019. Association for Computational Linguistics.
  21. [Shang et al., 2023] Chuyi Shang, Aryan Goyal, Lutfi Eren Erdogan, and Siddarth Ijju. Safeguard: A benchmark suite for evaluating attacks and defenses on llm safety. https: //devpost.com/software/safeguard-a1hfp4, 2023. Link
  22. [Shen et al., 2024] Xinyue Shen, Zeyuan Chen, Michael Backes, Yun Shen, and Yang Zhang. "Do Anything Now": Characterizing and Evaluating In-the-Wild Jail- break Prompts on Large Language Models. In Proceed- ings of the 2024 ACM SIGSAC Conference on Computer and Communications Security (CCS), pages 1671-1685, Salt Lake City, UT, USA, 2024. Association for Comput- ing Machinery.
  23. [Suo, 2024] Xuchen Suo. Signed-prompt: A new approach to prevent prompt injection attacks against llm-integrated applications. In AIP Conference Proceedings, volume 3194, page 040013. AIP Publishing LLC, 2024.
  24. [van den Oord et al., 2018] Aäron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with con- trastive predictive coding. CoRR, abs/1807.03748, 2018.
  25. [Vassilev et al., 2025] Aleksandr Vassilev, Alina Oprea, An- drew Fordyce, Hyrum Anderson, Xavier Davies, and Michael Hamin. Adversarial machine learning: A taxon- omy and terminology of attacks and mitigations. NIST Trustworthy and Responsible AI NIST AI 100-2e2025, National Institute of Standards and Technology, Gaithers- burg, MD, 2025.
  26. [Wallace et al., 2024] Eric Wallace, Kai Xiao, Reimar Leike, Lilian Weng, Johannes Heidecke, and Alex Beutel. The instruction hierarchy: Training llms to prioritize privileged instructions. arXiv preprint arXiv:2404.13208, 2024.
  27. [Wan et al., 2025] Fanqi Wan, Weizhou Shen, Shengyi Liao, Yingcheng Shi, Chenliang Li, Ziyi Yang, Ji Zhang, Fei Huang, Jingren Zhou, and Ming Yan. Qwenlong-l1: To- wards long-context large reasoning models with reinforce- ment learning, 2025.
  28. [Wang et al., 2025] Yiming Wang, Pei Zhang, Baosong Yang, Derek F. Wong, Zhuosheng Zhang, and Rui Wang. Embedding trajectory for out-of-distribution detection in mathematical reasoning. In Proceedings of the 38th In- ternational Conference on Neural Information Processing Systems (NeurIPS 2024), pages 42965-42999, Red Hook, NY, USA, 2025.
  29. Curran Associates Inc. [Willison, 2023]
  30. Simon Willison. Delimiters won't save you from prompt injection. https://simonwillison.net/2023/ May/11/delimiters-wont-save-you, 2023. Link
  31. [Xie et al., 2023] Yueqi Xie, Jingwei Yi, Jiawei Shao, Justin Curl, Lingjuan Lyu, Qifeng Chen, Xing Xie, and Fangzhao Wu. Defending chatgpt against jailbreak attack via self- reminders. Nature Machine Intelligence, 5(12):1486- 1496, 2023.
  32. [Yi et al., 2025] Jingwei Yi, Yueqi Xie, Bin Zhu, Emre Kici- man, Guangzhong Sun, Xing Xie, and Fangzhao Wu. Benchmarking and defending against indirect prompt in- jection attacks on large language models. In Proceedings of the 31st ACM SIGKDD Conference on Knowledge Dis- covery and Data Mining V. 1, pages 1809-1820, 2025.
  33. [Zhou et al., 2021] Wenxuan Zhou, Fangyu Liu, and Muhao Chen. Contrastive out-of-distribution detection for pre- trained transformers. In Proceedings of the 2021 Confer- ence on Empirical Methods in Natural Language Process- ing, pages 1100-1111, Online and Punta Cana, Dominican Republic, November 2021. Association for Computational Linguistics.

References were extracted automatically from the PDF and may contain errors.

Welcome Future Conferences AI Journal Division IJCAI Proceedings About IJCAI IJCAI Awards