Manuscript Offprint

arXiv:2608.27504

Circuit Discovery Helps Detect LLM Jailbreaking: A Mechanistic Interpretability Study

Paria Mehrbod, Boris Knyazev, Guy Wolf, Eugene Belilovsky, Geraldin Nanfack

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Despite extensive safety alignment, large language models (LLMs) remain vulnerable to jailbreak attacks that bypass safeguards to elicit harmful content. While prior work attributes this vulnerability to safety training limitations, the internal mechanisms by which LLMs process adversarial prompts remain poorly understood. We present a mechanistic analysis of the jailbreaking behavior in a large-scale, safety-aligned LLM, focusing on LLaMA-2-7B-chat-hf. Leveraging edge attribution patching and subnetwork probing, we systematically identify computational circuits responsible for generating affirmative responses to jailbreak prompts. Ablating these circuits during the first token prediction can reduce attack success rates by up to 80%, demonstrating its critical role in safety bypass. Our analysis uncovers key attention heads and MLP pathways that mediate adversarial prompt exploitation, revealing how important tokens propagate through these components to override safety constraints. These findings advance the understanding of adversarial vulnerabilities in aligned LLMs and pave the way for targeted, interpretable defense mechanisms based on mechanistic interpretability.

1. Introduction

Large language models (LLMs) show remarkable performance across various real-world tasks. LLMs underpin a growing range of applications, from automated code generation to conversational agents, and their deployment in real-world systems has scaled rapidly. To be able to generate safe contents, LLMs are finetuned to align with human values, thus refusing to generate contents that are harmless (Ouyang et al., 2022). Despite their success, even after being

fine-tuned, LLMs remain vulnerable to “jailbreak attacks”. These attacks are adversarial prompt techniques that manipulate input prompts to bypass built-in safety mechanisms leading to harmful responses (Zou et al., 2023). Empirical studies have demonstrated high attack success rates across popular models, including GPT-4 (Achiam et al., 2023), and LLaMA variants (Touvron et al., 2023), highlighting systemic weaknesses in current alignment protocols (Li et al., 2024; Andriushchenko et al., 2024).

Although Wei et al. (2023) have tried to elucidate why powerful LLMs are vulnerable to these attacks by linking LLM’s vulnerability to safety finetuning failure, it remains poorly understood how LLMs internally process these adversarial prompts. Mechanistic interpretability is a promising field that takes the challenge of uncovering the inner-working mechanisms of deep neural networks (Bereska, 2022). Mainstream methods include those that explain neural network behaviors by identifying circuits that are minimal computational subnetworks responsible for specific tasks or behaviors (Olah et al., 2020; Hanna et al., 2023). Through techniques such as activation patching, researchers have reverse-engineered circuits underlying tasks such as greater-than and indirect object identification (Hanna et al., 2023; Wang et al., 2022). However, these efforts have predominantly targeted small models and synthetic benchmarks (Sharkey et al., 2025).

In this paper, we tackle the problem of mechanically analyzing a more challenging task, notably the jailbreaking behavior in large-scale, safety-finetuned LLMs. Specifically, we focus on LLaMA-2-7B-chat, a conversational variant with around 7 billion parameters (Touvron et al., 2023). To our knowledge, this is the first work to systematically discover and characterize circuits that enable LLMs to produce affirmative responses to jailbreak prompts. We employ two well-known methods for circuit discovery, namely edge attribution patching—a gradient-based approximation of attribution patching and subnetwork probing (Syed et al., 2023; Cao et al., 2021).

Our investigation reveals a compact subnetwork that faithfully replicates the model’s jailbreak behavior. By ablating this circuit at the first token prediction, we show that models start to refuse to bypass safety measures with jailbreaks,

¹Concordia University ²Mila ³Samsung – SAIT AI Lab ⁴Université de Montréal. Correspondence to: Paria Mehrbod paria.mehrbod@mila.quebec.

The 2nd Workshop on Reliable and Responsible Foundation Models of the 42nd International Conference on Machine Learning, Vancouver, Canada. 2025. Copyright 2025 by the author(s).

thus reducing attack success rates. We analyze the structure and information flow within the discovered circuit, uncovering key attention heads and MLP pathways that mediate the bypass of safety measures.

We summarize our contributions as follows: (i) We apply the edge attribution patching method for automated circuit discovery tailored to jailbreak behaviors in large-scale LLMs, namely in LLaMA-2.7B-chat-hf. (ii) We identify a high-fidelity circuit responsible for unsafe completions under jailbreak prompts. (iii) We demonstrate that targeted ablation of the discovered circuit at the first token prediction substantially enhances resistance to jailbreak attacks.

References (24)