arXiv:2610.30202cs.CROct 2026

Manuscript Offprint

arXiv:2610.30202

MPIDetector: Detecting Multi-modal Prompt Injection via LLM-based Reasoning

Yiheng Li, Jingyue Li

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Yiheng Li

Paul G. Allen School of Computer Science & Engineering

University of Washington

Seattle, WA, USA

yihen14@cs.washington.edu

Jingyue Li

Department of Computer Science

Norwegian University of Science and Technology

Trondheim, Norway

jingyue.li@ntnu.no

Abstract—With the rapid integration of Multi-modal Large Language Models (MLLMs) into real-world applications, Prompt Injection (PI) has emerged as a critical security threat. Attackers can conceal malicious instructions within textual narratives or visual inputs to bypass safety alignment. Existing approaches, such as signature- and perplexity-based methods, rely heavily on pattern matchings, making them insufficient to detect sophisticated, cross-modal PI payloads. In this paper, we propose a novel detection framework, called MPIDetector, that leverages LLMs' intrinsic reasoning capabilities via few-shot In-Context Learning (ICL). Instead of fine-tuning, we provide the model with specific prompt templates and representative attack examples, enabling it to scrutinize the semantic intent of input across modalities. We constructed a comprehensive evaluation benchmark comprising eight textual and seven visual malicious categories, supplemented with benign datasets to rigorously test for false positives. Our evaluation across multiple leading LLMs, including Gemini-2.0-Flash, Qwen3-VL-32B-Instruct, and Doubao-seed-1.6-flash, demonstrates the efficacy and generalizability of this approach. The proposed method achieves up to 90.91% accuracy and 100% recall on textual tasks. In the visual domain, it achieves up to 99.28% accuracy while maintaining a 100% precision across all evaluated models. Crucially, when evaluated against 500 highly obfuscated environmental web-agent injections (WebInject), MPIDetector achieved a detection rate up to 99.80%. Comparisons with two baseline approaches for detecting textual PI payloads, along with two additional methods for visual input detection, demonstrate MPIDetector's superior accuracy. These results show that LLM-driven reasoning provides a robust, cross-modal defense against advanced prompt injections.

Index Terms—Prompt Injection, Large Language Models, Multi-modal Security, In-Context Learning

I. INTRODUCTION

The rapid proliferation of Multi-modal Large Language Models (MLLMs) has fundamentally transformed how users interact with artificial intelligence, extending capabilities beyond text to encompass complex visual inputs. However, this expanded attack surface has introduced critical security vulnerabilities, most notably the Prompt Injection (PI) threat. In a PI attack, malicious actors embed hidden instructions within seemingly benign textual narratives or images to hijack the model's original instructions and bypass safety alignments [1]–[3].

Current state-of-the-art defenses primarily rely on signature-based filtering, perplexity-based anomaly detection, or pattern matching methods [1], [4]–[7]. While effective against naive textual and image exploits, these conventional practices struggle to generalize against sophisticated, cross-modal injections that obscure malicious intent within complex semantic structures [2], [4]. Consequently, exploring how to defend against these evolving, multi-modal threats without constantly retraining defensive classifiers has become one of the critical challenges in AI security. Recent advancements, such as the MalCVE framework [8], have demonstrated the remarkable reasoning capabilities of LLMs in analyzing complex malware, prompting the compelling question of whether LLMs can independently reason about and detect adversarial prompt injection. Thus, this study aims to address two research questions.

• RQ1: How to leverage LLMs’ intrinsic reasoning capabilities to robustly distinguish between legitimate, albeit ambiguous, user queries and deliberate cross-modal injection attempts?

• RQ2: How to design a unified detection framework that effectively generalizes across both textual and visual modalities while maintaining a near-zero false positive rate to preserve the user experience?

To answer these research questions, we propose a novel, unified detection framework, MPIDetector, based on few-shot In-Context Learning (ICL). Instead of relying on resource-intensive fine-tuning or superficial feature extraction, our method provides the LLM with carefully curated prompt templates and representative attack exemplars. This empowers the model to act as a security guardian, actively scrutinizing and reasoning about the underlying semantic intent of the input across different modalities.

We evaluate our framework across multiple leading LLMs (including Gemini-2.0-Flash, Qwen3-VL-32B-Instruct, and Doubao-seed-1.6-flash) on a comprehensive benchmark comprising over 3,800 samples. Specifically, this evaluation utilizes 300 textual payloads, over 2,000 visual adversarial images, 500 highly obfuscated web-agent samples, and 1,000 benign images integrated across modalities to precisely measure the false-positive rate. The results demonstrate the efficacy and generalizability of our approach: it achieves up to 90.91% accuracy and 100% precision in the textual domain, and up to 99.28% accuracy with a 100% precision in the visual domain. Most notably, our framework demonstrates robustness against highly obfuscated web-agent injections (WebInject), achieving a 99.80% detection rate. Comparisons with both the perplexity-based approach [5] and the fine-tuned safety classifier [6] in the textual domain demonstrate that the in-context learning (ICL) paradigm of MPIDetector achieves significantly higher recall. In the visual domain, comparisons with rule-based [1] and visual anomaly-based [7] approaches further highlight the superior accuracy of MPIDetector.

The primary contribution of this work is the empirical validation that LLM-driven reasoning reduces false positives and significantly outperforms traditional baselines, offering a robust, adaptable defense against multi-modal prompt injections.

The remainder of this paper is structured as follows: Section II reviews related work in prompt injection and LLM-based security. Section III details our proposed ICL reasoning methodology. Section IV presents the experimental setup and results. Section V discusses the results, and Section VI concludes the paper.