Knowledge-to-Jailbreak: One Knowledge Point Worth One Attack

Shangqing Tu, Zhuoran Pan, Wenxuan Wang, Zhexin Zhang, Yuliang Sun, Jifan Yu, Hongning Wang, Lei Hou, Juanzi Li · OpenReview

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. However, testing the domain-specific safety of LLMs is challenging due to the lack of domain knowledge-driven attacks in existing benchmarks. To bridge this gap, we propose a new task, knowledge-to-jailbreak, which aims to generate jailbreaks from domain knowledge to evaluate the safety of LLMs when applied to those domains. 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 relevant to the given knowledge and harmful to the target LLMs. 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.

Introduction: The Gap in Domain-Specific Safety

As Large Language Models (LLMs) are increasingly deployed in specialized sectors like law, finance, and medicine, their safety profiles must be scrutinized beyond general conversational risks. Current jailbreaking research—the study of adversarial prompts designed to bypass safety filters—primarily focuses on high-frequency, "common sense" harmful queries, such as instructions for building a bomb. While models are often well-guarded against these generic attacks, they remain vulnerable to technical, low-frequency queries that leverage specific domain knowledge.

Comparison between existing general attacks and uncovered domain-specific attacks using technical knowledge.

Two major gaps exist in current safety testing:

  1. Lack of Professionalism: Generic prompts are easily detected. Technical vulnerabilities require domain-specific context.
  2. Insufficient Coverage: General datasets fail to test how a specialized LLM (e.g., a medical or legal assistant) might respond to a highly technical query that could lead to dangerous real-world outcomes.

The Knowledge-to-Jailbreak Framework

To address these gaps, we introduce the Knowledge-to-Jailbreak task. The objective is to automatically transform professional domain knowledge into potent jailbreaking attacks that are both effective at bypassing safety guards and highly relevant to the technical input.

We developed a three-stage pipeline to create an automated "jailbreak-generator":

The three-stage pipeline for Knowledge-to-Jailbreak: Data Collection, Generator Training, and Deployment.

Stage 1: Data Collection (Reverse Generation)

Because no dedicated "knowledge-to-jailbreak" dataset existed, we constructed one by aggregating 12,974 plain jailbreaks from six public datasets. Using a Dense Passage Retriever (DPR), we mapped these prompts to relevant Wikipedia snippets, creating a foundation of knowledge-jailbreak pairs.

Stage 2: Knowledge Integration & Mutation

The retrieved knowledge was integrated with the jailbreak prompts. To enhance their effectiveness, we employed a "mutation" strategy. Among various techniques like misspelling or structural changes, the "rephrase" strategy—rewriting the prompt into a specific adversarial template—proved most effective. We iteratively refined these prompts until they successfully bypassed a target model (Llama2-7b-chat).

Stage 3: Training the Generator

We fine-tuned a Llama2-7b model on 8,210 successful pairs. This resulting jailbreak-generator can take raw technical knowledge and output a sophisticated jailbreak prompt in a single pass. Unlike iterative methods like PAIR or AutoDAN, our generator operates "zero-shot" at inference time, significantly reducing computational overhead.

Experimental Results and Insights

The generator was evaluated against 8 target LLMs, including GPT-4 and domain-specific models like LawChat, across 13 domains.

Attack Effectiveness

On GPT-3.5-Turbo, the generator achieved an Attack Success Rate (ASR) of 29.0% in the Management domain, nearly tripling the performance of the PAIR baseline (11.0%). Furthermore, in Out-of-Distribution (OOD) tests involving hazardous chemicals, the generator produced attacks comparable in harmfulness to those meticulously crafted by human experts.

Knowledge as a "Trojan Horse"

A key insight from our research is that technical knowledge acts as a "Trojan Horse." When an LLM is provided with factual context, it often perceives the request as a legitimate instruction or background task. This factual framing lowers the model's internal safety guard, making it more likely to comply with the underlying malicious intent.

Knowledge Relevance

Using ROUGE-1 scores, we confirmed that our generated attacks maintain high fidelity to the input technical knowledge. While baseline methods often "drift" into generic jailbreak scripts, our framework ensures the attack remains grounded in the specific domain vulnerability.

Conclusion

The Knowledge-to-Jailbreak framework demonstrates that even "innocuous" factual snippets can be weaponized to bypass LLM safety guards. Our findings suggest that current defensive strategies, such as goal prioritization, are insufficient for specialized domains. Future work must focus on updating ethical frameworks to recognize when technical information is being used to facilitate harmful activities, ensuring that domain-specific LLMs are as safe as they are capable.

Data and code are available at: https://github.com/THU-KEG/Knowledge-to-Jailbreak/

Summary updated

BibTeX
@inproceedings{tu2024knowledge,
  author = {Shangqing Tu and Zhuoran Pan and Wenxuan Wang and Zhexin Zhang and Yuliang Sun and Jifan Yu and Hongning Wang and Lei Hou and Juanzi Li},
  title = {{Knowledge-to-Jailbreak: One Knowledge Point Worth One Attack}},
  booktitle = {ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
  year = {2024},
}
Figure