X-Boundary: Establishing Exact Safety Boundary to Shield LLMs from Jailbreak Attacks without Compromising Usability

Xiaoya Lu, Dongrui Liu, Yi Yu, Luxin Xu, Jing ShaoEMNLP 2025 · OpenReview

TL;DR

This paper introduces X-Boundary, a novel defense mechanism for Large Language Models (LLMs) that establishes a precise boundary between safe and harmful content representations. Unlike previous methods that compromise usability (e.g., over-refusal), X-Boundary effectively shields LLMs from jailbreak attacks while preserving general capabilities and even accelerating training.

What Problem Does This Paper Address?

Large Language Models (LLMs) are increasingly integrated into various applications, but they are vulnerable to "jailbreak" attacks. These attacks use carefully crafted prompts to elicit harmful or undesirable responses. While existing defense methods can improve LLM robustness against these attacks, they often come at the cost of usability. This trade-off manifests as reduced general capabilities (the "alignment tax") or an "over-refusal" problem, where LLMs incorrectly reject safe and legitimate prompts. The core challenge is to create defenses that are both effective against malicious inputs and don't hinder the LLM's ability to perform its intended tasks.

Methods

The authors propose X-Boundary, a defense strategy that focuses on the internal representation space of LLMs. They hypothesize that existing defenses fail to create a clear distinction between representations of safe and harmful content. X-Boundary aims to explicitly formulate this distinction boundary.

The core idea is to train the LLM to:

  1. Push harmful representations away from boundary-safe representations: This is achieved through a "separation loss" ($L_s$) that encourages orthogonality between harmful and safe feature representations.
  2. Erase harmful representations: An "erase loss" ($L_e$) is used to orthogonalize harmful representations from their original, unlearned counterparts.
  3. Preserve safe representations: A "retain loss" ($L_r$) ensures that representations of safe and boundary-safe content are minimally altered, preserving usability.

These losses are combined into a single objective function, guiding the LLM to learn a precise distinction boundary. This approach allows for the precise removal of harmful content without disrupting safe content.

Datasets

The paper utilizes several datasets for training and evaluation:

  • OR-Bench-80K: Used to generate boundary-safe QA pairs.
  • UltraChat: Used as instruction-following data.
  • SafeMTData: A dataset derived from the circuit breaker training dataset, used for multi-turn defense training.
  • HarmBench: A benchmark for evaluating multi-turn attacks.
  • Specific datasets for various attacks: ActorAttack, RedQueen, Crescendo, XSTest, OKTest, OR-Bench, PHTest.
  • General capability benchmarks: MMLU, GSM8K, HumanEval.

Key Insights and Ideas

  • The "alignment tax" is a representation problem: The authors pinpoint the root cause of the defense-usability trade-off to the LLM's internal representation space. Existing methods fail to learn a precise boundary, leading to safe representations being mistakenly flagged as harmful.
  • Explicit boundary formulation is key: Instead of implicitly learning a boundary, X-Boundary explicitly enforces one, leading to more precise separation and reduced over-refusal.
  • Pushing apart, not just masking: X-Boundary doesn't just mask or remap harmful representations; it actively pushes them away from safe ones, creating a more robust separation.
  • Faster learning through better representation: The theoretical analysis suggests that X-Boundary's approach to representation engineering can lead to faster convergence during training, potentially due to more structured feature learning.

Key Results

  • State-of-the-art defense: X-Boundary achieves state-of-the-art performance against both single-turn and multi-turn jailbreak attacks, reducing ASR by over 70% in some cases.
  • Reduced over-refusal: It significantly lowers the over-refusal rate (ORR) by approximately 20% compared to other defense methods.
  • Preserved general capability: X-Boundary maintains nearly complete general capability, with minimal decline in performance on benchmarks like coding and reasoning.
  • Faster training: Empirically and theoretically verified, X-Boundary accelerates the training convergence process by up to 26.47%.
  • Effective across LLM sizes: The method shows consistent effectiveness across various LLM sizes, including large reasoning models (LRMs).

Limitations and Future Work

  • Black-box model limitation: X-Boundary relies on representation-level intervention, making it inapplicable to black-box models.
  • Pre-training stage: The authors acknowledge that they haven't thoroughly investigated resolving the trade-off during the pre-training stage, as these processes are often closed-source.
  • Future work: The paper suggests future research could focus on enhancing content moderation mechanisms, exploring ethical usage protocols, and potentially adapting X-Boundary to pre-training stages. They also note that further research could investigate strategies to prevent the reduction in output length observed in some cases.

Summary updated

Abstract

With the widespread application of large language models (LLMs) across various domains, techniques for enhancing their security have progressed rapidly. In this paper, we reveal that although existing defense methods can improve the robustness of LLMs against jailbreaks, they compromise usability, i.e., reducing general capabilities or causing the over-refusal problem. From the perspective of LLM mechanism interpretability, we discover that these methods fail to establish a boundary that exactly distinguishes safe and harmful feature representations. Therefore, boundary-safe representations close to harmful representations are inevitably disrupted, leading to a decline in usability. To address this issue, we propose X-Boundary to push harmful representations away from boundary-safe representations and obtain an exact distinction boundary. In this way, harmful representations can be precisely erased without disrupting safe ones. Experimental results show that X-Boundary achieves state-of-the-art defense performance against both single-turn and multi-turn jailbreak attacks, while reducing the over-refusal rate by about 20% and maintaining nearly complete general capability. Furthermore, we theoretically prove and empirically verify that X-Boundary can accelerate the convergence process during training.
BibTeX
@inproceedings{lu2025x,
  author = {Xiaoya Lu and Dongrui Liu and Yi Yu and Luxin Xu and Jing Shao},
  title = {{X-Boundary: Establishing Exact Safety Boundary to Shield LLMs from Jailbreak Attacks without Compromising Usability}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2025},
  url = {https://openreview.net/forum?id=R8iguXotjr},
}
Figure