CodeChameleon: Personalized Encryption Framework for Jailbreaking Large Language Models

Huijie Lv, Xiao Wang, Yuansen Zhang, Caishuang Huang, Shihan Dou +4 more
2/26/2024
86 citations
cs.CLcs.AIcs.CR

Official code: huizhang-L/CodeChameleon (30 stars, Python, last commit 2024-03-20).

Abstract

Adversarial misuse, particularly through `jailbreaking' that circumvents a model's safety and ethical protocols, poses a significant challenge for Large Language Models (LLMs). This paper delves into the mechanisms behind such successful attacks, introducing a hypothesis for the safety mechanism of aligned LLMs: intent security recognition followed by response generation.

Show full abstract

Grounded in this hypothesis, we propose CodeChameleon, a novel jailbreak framework based on personalized encryption tactics. To elude the intent security recognition phase, we reformulate tasks into a code completion format, enabling users to encrypt queries using personalized encryption functions. To guarantee response generation functionality, we embed a decryption function within the instructions, which allows the LLM to decrypt and execute the encrypted queries successfully. We conduct extensive experiments on 7 LLMs, achieving state-of-the-art average Attack Success Rate (ASR). Remarkably, our method achieves an 86.6\% ASR on GPT-4-1106.

View on arXivView PDF

Code Implementations(1)

302PythonFeb 26, 20242 years ago

Similar Papers

Cite this paper

@article{lv2024codechameleon,
  title  = {CodeChameleon: Personalized Encryption Framework for Jailbreaking Large Language Models},
  author = {Huijie Lv and Xiao Wang and Yuansen Zhang and Caishuang Huang and Shihan Dou and Junjie Ye and Tao Gui and Qi Zhang and Xuanjing Huang},
  year   = {2024},
  eprint = {2402.16717},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2402.16717v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2402.16717.svg)](https://codeofpaper.com/paper/2402.16717)

Discussion