Hijacking Large Language Models via Adversarial In-Context Learning

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Zhou, Xiangyu, Qiang, Yao, Zade, Saleh Zare, Khanduri, Prashant, Zhu, Dongxiao
Format: Preprint
Published: 2023
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866909626684932096
author Zhou, Xiangyu
Qiang, Yao
Zade, Saleh Zare
Khanduri, Prashant
Zhu, Dongxiao
author_facet Zhou, Xiangyu
Qiang, Yao
Zade, Saleh Zare
Khanduri, Prashant
Zhu, Dongxiao
contents In-context learning (ICL) has emerged as a powerful paradigm leveraging LLMs for specific downstream tasks by utilizing labeled examples as demonstrations (demos) in the preconditioned prompts. Despite its promising performance, crafted adversarial attacks pose a notable threat to the robustness of LLMs. Existing attacks are either easy to detect, require a trigger in user input, or lack specificity towards ICL. To address these issues, this work introduces a novel transferable prompt injection attack against ICL, aiming to hijack LLMs to generate the target output or elicit harmful responses. In our threat model, the hacker acts as a model publisher who leverages a gradient-based prompt search method to learn and append imperceptible adversarial suffixes to the in-context demos via prompt injection. We also propose effective defense strategies using a few shots of clean demos, enhancing the robustness of LLMs during ICL. Extensive experimental results across various classification and jailbreak tasks demonstrate the effectiveness of the proposed attack and defense strategies. This work highlights the significant security vulnerabilities of LLMs during ICL and underscores the need for further in-depth studies.
format Preprint
id arxiv_https___arxiv_org_abs_2311_09948
institution arXiv
publishDate 2023
record_format arxiv
spellingShingle Hijacking Large Language Models via Adversarial In-Context Learning
Zhou, Xiangyu
Qiang, Yao
Zade, Saleh Zare
Khanduri, Prashant
Zhu, Dongxiao
Machine Learning
Computation and Language
Cryptography and Security
In-context learning (ICL) has emerged as a powerful paradigm leveraging LLMs for specific downstream tasks by utilizing labeled examples as demonstrations (demos) in the preconditioned prompts. Despite its promising performance, crafted adversarial attacks pose a notable threat to the robustness of LLMs. Existing attacks are either easy to detect, require a trigger in user input, or lack specificity towards ICL. To address these issues, this work introduces a novel transferable prompt injection attack against ICL, aiming to hijack LLMs to generate the target output or elicit harmful responses. In our threat model, the hacker acts as a model publisher who leverages a gradient-based prompt search method to learn and append imperceptible adversarial suffixes to the in-context demos via prompt injection. We also propose effective defense strategies using a few shots of clean demos, enhancing the robustness of LLMs during ICL. Extensive experimental results across various classification and jailbreak tasks demonstrate the effectiveness of the proposed attack and defense strategies. This work highlights the significant security vulnerabilities of LLMs during ICL and underscores the need for further in-depth studies.
title Hijacking Large Language Models via Adversarial In-Context Learning
topic Machine Learning
Computation and Language
Cryptography and Security
url https://arxiv.org/abs/2311.09948