Abstract
Large language models (LLMs) have been increasingly applied to various domains, which triggers increasing concerns about LLMs' safety on specialized domains, e.g. medicine. Despite prior explorations on general jailbreaking attacks, there are two challenges for applying existing attacks on testing the domain-specific safety of LLMs: (1) Lack of professional knowledge-driven attacks, (2) Insufficient coverage of domain knowledge. To bridge this gap, we propose a new task, knowledge-to-jailbreak, which aims to generate jailbreaking attacks from domain knowledge, requiring both attack effectiveness and knowledge relevance. We collect a large-scale dataset with 12,974 knowledge-jailbreak pairs and fine-tune a large language model as jailbreak-generator, to produce domain knowledge-specific jailbreaks. Experiments on 13 domains and 8 target LLMs demonstrate the effectiveness of jailbreak-generator in generating jailbreaks that are both threatening to the target LLMs and relevant to the given knowledge. We also apply our method to an out-of-domain knowledge base, showing that jailbreak-generator can generate jailbreaks that are comparable in harmfulness to those crafted by human experts.
The Problem: Domain-Specific Safety Gaps
Most current jailbreaking research focuses on general harmful queries, such as "how to make a bomb." Because these prompts are common and broad, they are relatively easy for developers to filter or train against. However, as LLMs are increasingly deployed as specialized assistants (e.g., AI doctors or legal advisors), a new "long-tail" risk emerges.
An attacker might use obscure, professional knowledge to bypass safety filters that aren't tuned for that specific domain. The authors identify two major gaps: a lack of professional knowledge-driven attacks and insufficient coverage of low-frequency domain knowledge where safety risks might hide.
Methodology: The Three-Stage Pipeline
The authors propose a three-stage pipeline to build a jailbreak-generator capable of producing highly relevant and effective attacks in a single pass:
- Data Collection (Reverse Generation): Since no "knowledge-to-jailbreak" dataset existed, they started with 12,974 known plain jailbreaks. They used a Dense Passage Retriever (DPR) to find relevant Wikipedia snippets for each. They then "knowledge-enhanced" these prompts and used a mutation strategy to ensure the resulting prompts successfully attacked a target model (Llama2-7b-chat).
- Training: They fine-tuned a Llama2-7b-base model using Supervised Fine-Tuning (SFT) on 8,210 high-quality pairs of [Knowledge Snippet → Successful Jailbreak].
- Deployment: The resulting model can take any new piece of knowledge and generate a jailbreak prompt that is both effective at bypassing safety and highly relevant to that specific knowledge.
Unlike baseline methods like PAIR or AutoDAN, which require multiple iterative "conversations" with a target LLM to find a weakness, this generator works in a single pass, making it significantly more efficient.
Key Results and Insights
- Attack Success Rate (ASR): On the GPT-3.5-Turbo model, the jailbreak-generator achieved an ASR of 29.0% in the Management domain, significantly higher than the PAIR (11.0%) and AutoDAN (7.0%) baselines.
- Knowledge as a "Trojan Horse": The researchers found that providing a technical knowledge snippet as context actually makes an LLM more likely to respond to a harmful query. The model perceives the context as "helpful information" and lowers its guard.
- Generalization Power: The generator doesn't just memorize attacks; it learns a strategy. It performed well on domains it never saw during training (like Management or Geography) and produced attacks comparable to human experts in the chemistry domain.
- Relevance Matters: Using ROUGE-1 scores, the authors showed their method stays much closer to the source knowledge than baselines, which often mutate the prompt so much it loses its original domain-specific intent.
Conclusion and Future Work
While the paper demonstrates a powerful new attack, the authors acknowledge this is part of an ongoing safety race. They explicitly state that their goal is to provide a tool for testing and improving LLM safety. Future work will focus on using these generated attacks to "adversarially train" models to be more robust. Understanding these vulnerabilities now is critical before LLMs are given more autonomy in sensitive professional fields.
Data and code are available at: https://github.com/THU-KEG/Knowledge-to-Jailbreak/
Summary updated