Embedding-Based Machine Learning for Detecting Direct and Indirect Prompt Injection Attacks
Year: 2026
Type: dissertation
Abstract: Large Language Models (LLMs) are increasingly integrated into applications that process external and often untrusted data, which introduces new security risks. One of the most important of these is prompt injection, where malicious instructions are embedded in input text in order to manipulate the behavior of the model. This thesis investigates the detection of prompt injection across three progressively more complex settings. First, classical machine learning models trained on sentence embeddings are evaluated on direct prompt injection tasks, showing strong performance. Second, the problem is extended to indirect prompt injection, where malicious instructions are embedded within longer, context-rich documents. Two datasets are constructed for this purpose: a simpler dataset based on news articles, and a more diverse multi-domain dataset combining news, summarization, and email content. The results show that classifier performance drops significantly in the more realistic setting, highlighting the limitations of document-level representations. To address this challenge, the thesis explores document-level aggregation strategies based on chunking. Documents are divided into smaller segments, which are individually analyzed and combined using a max-probability aggregation method. This approach leads to a substantial improvement in detection performance, demonstrating that localized analysis is more effective than treating the document as a single unit. Overall, the results highlight the importance of dataset realism and input representation in prompt injection detection. The findings suggest that methods evaluated in simplified settings may overestimate real-world performance, and that effective detection requires focusing on localized patterns within complex and heterogeneous text.
Language: English
Subfield: Artificial Intelligence
Field: Computer Science
Domain: Physical Sciences
Open Access status: green
OpenAlex ID: W7164293653
