Hijacking Large Language Models via Adversarial In-Context Learning
Preprint
Abstract
In-context learning (ICL) has emerged as a powerful paradigm leveraging LLMs for specific tasks by utilizing labeled examples as demonstrations in the precondition prompts. Despite its promising performance, ICL suffers from instability with the choice and arrangement of examples. Additionally, crafted adversarial attacks pose a notable threat to the robustness of ICL. However, existing attacks are either easy to detect, rely on external models, or lack specificity towards ICL. To address these issues, this work introduces a novel transferable attack for ICL, aiming to hijack LLMs to generate the targeted response. The proposed LLM hijacking attack leverages a gradient-based prompt search method to learn and append imperceptible adversarial suffixes to the in-context demonstrations. Extensive experimental results on various tasks and datasets demonstrate the effectiveness of our LLM hijacking attack, resulting in a distracted attention towards adversarial tokens, consequently leading to the targeted unwanted outputs.Keywords
All Related Versions
This publication has 15 references indexed in Scilit:
- Jailbreaking Black Box Large Language Models in Twenty Queries2025
- "Do Anything Now": Characterizing and Evaluating In-The-Wild Jailbreak Prompts on Large Language Models2024
- Exploiting Programmatic Behavior of LLMs: Dual-Use Through Standard Security Attacks2024
- PromptRobust: Towards Evaluating the Robustness of Large Language Models on Adversarial Prompts2023
- Impact of Pretraining Term Frequencies on Few-Shot Numerical Reasoning2022
- Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivity2022
- BERT-ATTACK: Adversarial Attack Against BERT Using BERT2020
- AutoPrompt: Eliciting Knowledge from Language Models with Automatically Generated Prompts2020
- BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and Comprehension2020
- TextBugger: Generating Adversarial Text Against Real-world Applications2019