Detecting and defending against indirect prompt injection attacks with instructionsDefending against Indirect Prompt Injection by Instruction Detection
AI summary
The paper proposes InstructDetector, a detection method that uses LLM behavioral states to identify indirect prompt injection (IPI) attacks. The method holds that IPI relies on instructions embedded in external content to change the model's behavioral state, on which basis the authors extract hidden states and gradients from intermediate layers and combine the two as discriminative features for instruction detection. Detection accuracy is 99.60% in the in-domain setting and 96.90% in the out-of-domain setting, and it reduces the attack success rate to 0.03% on the BIPIA benchmark. The code is publicly available on GitHub.