A Hitchhiker's Guide to Jailbreaking ChatGPT via Prompt Engineering

Yi Liu, Gelei Deng, Zhengzi Xu, Yuekang Li, Yaowen Zheng, Ying Zhang, Lida Zhao, Tianwei Zhang, Kailong Wang

Introduction

To ensure responsible AI deployment, providers like OpenAI implement safety filters to prevent Large Language Models (LLMs) from generating harmful, illegal, or biased content. However, a community of "adversarial prompt engineers" has emerged, sharing "jailbreaks"—complex templates designed to trick the model into ignoring its restrictions. While these jailbreaks have been widely discussed in online forums, they lacked rigorous scientific analysis until now. This research presents the first systematic taxonomy and large-scale empirical study of jailbreak prompts, analyzing 78 unique patterns against GPT-3.5 and GPT-4.

The Jailbreak Phenomenon

A jailbreak occurs when a user provides an adversarial input that bypasses the model's safety guardrails. For example, a direct request for malware instructions is typically refused. However, by wrapping the request in a fictional scenario or a specific role-play, the model can be induced to provide the prohibited information.

Comparison of Normal Mode refusal versus a successful Jailbreak Mode response using role-play.

Methodology and Taxonomy

The researchers adopted a "bottom-up" approach to categorize the chaos of online jailbreaks. They collected 78 verified prompts from community sources and manually classified them into a two-layer hierarchy consisting of three broad strategies subdivided into ten specific patterns.

  1. Pretending: Using role-play or assumed responsibility to create cognitive dissonance.
  2. Privilege Escalation: Attempting to gain higher-level access, such as "Sudo Mode."
  3. Attention Shifting: Forcing the model to focus on the logic of a task (like translation or text continuation) rather than the prohibited content itself.
The systematic taxonomy of jailbreak strategies and patterns identified in the study.

To test these patterns, the authors conducted a massive experiment involving 62,400 queries. They tested the 78 jailbreak prompts against 40 "malicious questions" spanning eight prohibited scenarios defined by OpenAI’s usage policy, including adult content, fraud, and illegal activities.

Key Insights and Results

The Dominance of "Pretending"

A staggering 97.44% of jailbreak prompts utilize the "Pretending" strategy. This suggests that LLMs are highly susceptible to persona-based attacks, where the model prioritizes staying in character over following its safety training. Patterns like "Character Role Play" and "Assumed Responsibility" were found to be the most prevalent across the dataset.

Model Evolution and Resilience

The study compared different versions of GPT-3.5 and GPT-4 over a three-month period. The results show that while newer models are more resilient, they are not immune:

  • GPT-4 is Safer: GPT-4 (version 0613) showed a lower overall jailbreak success rate (30.20%) compared to GPT-3.5 (53.08%).
  • Iterative Improvement: The success rate of jailbreaks dropped significantly between early and late versions of both models, proving that iterative safety fine-tuning is effective.
  • Attention Shifting Vulnerability: While GPT-4 is generally more robust, it remains particularly vulnerable to "Attention Shifting" patterns like Logical Reasoning and Text Continuation. By distracting the model with a complex logical task, attackers can still slip past filters.

The HGD Blind Spot

One of the most surprising findings was that both GPT-3.5 and GPT-4 had a 100% success rate in the "High-risk Government Decision-making" (HGD) category without even needing a jailbreak. This indicates a significant gap in the models' default safety training for that specific policy area.

Conclusion

This research demonstrates that while AI providers are making progress in securing LLMs, sophisticated prompt engineering remains a significant threat. The susceptibility of even advanced models like GPT-4 to specific linguistic "tricks" highlights the ongoing arms race between safety researchers and adversarial users. By providing a systematic taxonomy of these attacks, this study lays the foundation for building more robust, pattern-aware safety filters in the future.

Summary updated

BibTeX
@inproceedings{liu2024hitchhiker,
  author = {Yi Liu and Gelei Deng and Zhengzi Xu and Yuekang Li and Yaowen Zheng and Ying Zhang and Lida Zhao and Tianwei Zhang and Kailong Wang},
  title = {{A Hitchhiker's Guide to Jailbreaking ChatGPT via Prompt Engineering}},
  booktitle = {SEA4DQ@SIGSOFT FSE},
  year = {2024},
  doi = {10.1145/3663530.3665021},
}
Figure