Skip to content
Preprint

Robust Context-Aware Detection of Malicious Instructions in Text

Aug 2026 · 1 citation · 38 references
Computer Science

TL;DR

The proposed approach for malicious sentence classification that is both context- and query-aware and outperforms state-of-the-art IPI defense baselines under static attacks, while in the case of adaptive attacks, the AT variants provide significantly higher utility, lower attack success rate, and often both.

Abstract

The remarkable instruction-following ability of modern LLMs has enabled their practical use as the minds of agents that can autonomously complete increasingly complex tasks. Therein, however, also lies their vulnerability to attacks which embed malicious instructions in text, common variants of which are known as indirect prompt injection (IPI). A fundamental task in addressing this vulnerability is successful segmentation of a given text into benign and malicious sentences (if any). While a number of approaches for this task have been proposed, no detector combines query-relative detection at the segment level, and none are hardened against adaptive evasion attacks realizable in agentic executions. We address the former limitation by developing an approach for malicious sentence classification that is both context- and query-aware. Next, to harden the resulting classifier against evasion, we present two adversarial training methods. The first is directly adapted feature-space adversarial training (AT) in which evasions are approximated using projected-gradient-based optimization in the embedding space. The second simulates realizable evasion attacks in the AT loop through LLM-based paraphrasing. Crucially, we parametrize both AT variants to facilitate a smooth tradeoff between utility and attack robustness. In extensive experiments using indirect prompt injection benchmarks we show that the proposed approach outperforms state-of-the-art IPI defense baselines under static attacks, while in the case of adaptive attacks, our AT variants provide significantly higher utility, lower attack success rate, and often both. Finally, we show that the best AT parameters can depend intimately on the particular application domain. Consequently, domain-dependent tuning of malicious text detectors is likely necessary in practice. Our code is publicly available at https://github.com/tavia-liu/CAD.

View source

Similar papers

Review Sep 2026

The adversarial game between detection and evasion: A survey of anti-detection techniques for machine-generated texts.

This paper systematically synthesizes 27 studies of attacks against MGTD and the available evidence on corresponding defenses, categorizing existing research into four major types of evasion strategies: watermark attacks, paraphrasing attacks, prompt-based attacks, and adversarial-text attacks, and summarizes the avail...

De-Yu Meng, Tad Gonsalves · 0 citations
Jul 2026

Just Testing, Move Along: Evasion of LLM-based System Log Interpretation by Prompt Injection

This paper presents a framework for evaluating prompt injection attacks against LLM-based log interpretation using log traces generated during real cyber attacks, and creates adversarial examples through generic injection generation, refinement, and attack-specific optimization.

Max Landauer, F. Skopik, Markus Wurzenberger et al. · 0 citations

DRIP: Defending Prompt Injection via Token-wise Representation Editing and Residual Fusion

DRIP aims to achieve a new security-utility balance by “de-instructionalization”, i.e., precisely removing the instruction semantics from tokens in the data section while preserving their data semantics and robustly maintain the effectiveness of the intended instruction, even against strong adversarial content.

Zhiyong Huang, Jin Dong · 0 citations
#machine learning Preprint Aug 2026

REPLICANT: Learning Policies for Evading and Hardening Malware Detectors

This work presents Replicant, a deep reinforcement learning framework that learns the realistic task of evasion under a strict label-only black-box threat model and demonstrates that learning the task of evasion not only results in stronger attack performance but provides a better signal for hardening malware detectors...

Shae McFadden, Ilias Tsingenopoulos, Mario D'Onghia et al. · 0 citations
Open access Aug 2026

Real-Time Detection and Mitigation of Prompt Injection Attacks in LLM-Integrated Enterprise Systems

Large language models (LLMs) embedded in enterprise workflows cannot structurally distinguish legitimate instructions from adversarial ones in the same token stream, making prompt injection OWASP's top LLM risk for two consecutive editions a persistent threat across direct and indirect vectors. This paper presents Prom...

Fatimah Alhamzawi · 0 citations
Preprint Aug 2026

Your Agentic LLMs Secretly Encode Indirect Prompt-Injection Exposure in Hidden States

A probe-gated reasoning-based defense is introduced to bridge a knowledge-action gap in agentic LLMs when they are exposed to IPI attacks, and an analysis framework is introduced that identifies natural-language explanations strongly correlated with probe-captured signals.

Jianshuo Dong, Yiming Liu, Maosen Zhang et al. · 1 citation · ⚡1

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.