Dissecting the Black Box: Circuit-Level Analysis of LLM Vulnerability Detection
On the map: Mechanistic interpretability → Steering and probing for LLM safety
Abstract (arXiv)
Large language models (LLMs) can detect software vulnerabilities, but how do they actually identify vulnerable code? We address this question using mechanistic interpretability; analyzing the internal computations of a neural network to understand its reasoning process.Using Circuit Tracer on Gemma-2-2b, we trace the computational pathways activated when the model classifies 472 C/C++ code samples as vulnerable or safe. Our analysis reveals a surprising finding: the model primarily relies on safety detectors, attention heads that recognize safe coding patterns, rather than directly detecting vulnerability signatures. When these safety detectors fail to activate, the model classifies code as vulnerable. We identify the critical neural components: specific attention heads in early layers (L5, L7) that focus on safety patterns, and Multilayer Perceptron (MLP) neurons in Layer 7 that encode vulnerability-related features. Ablation experiments confirm their causal role; removing Layer 11 drops vulnerability detection accuracy from 100% to 6%, while ablating just 20 neurons in Layer 7 reduces it by 50%.Our findings show that LLM vulnerability detection uses sparse, interpretable circuits (only 16% of model capacity), enabling circuit-level explanations for security predictions and targeted improvements to detection systems.
Key facts. No citing papers in the map yet (data through 14 Oct 2026). Placed in Steering and probing for LLM safety, one of 13 directions in Mechanistic interpretability. Builds on 14 of its 28 references that are in the map. First posted on arXiv 28 May 2026.
Builds on
14 of 28 references.
References · 14
- 2017Attention Is All You Needcited by 60,361
- 2022Locating and Editing Factual Associations in GPTcited by 2,691
- 2023Representation Engineering: A Top-Down Approach to AI Transparencycited by 1,336
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,310
- 2022Interpretability in the Wild: a Circuit for Indirect Object Identification in GPT-2 smallcited by 1,165
- 2017Visualizing the Loss Landscape of Neural Netscited by 1,130
- 2022In-context Learning and Induction Headscited by 964
- 2023Progress measures for grokking via mechanistic interpretabilitycited by 839
- 2021Do Vision Transformers See Like Convolutional Neural Networks?cited by 675
- 2024Sparse Feature Circuits: Discovering and Editing Interpretable Causal Graphs in Language Modelscited by 435
- 2024Mechanistic Interpretability for AI Safety -- A Reviewcited by 422
- 2024Vulnerability Detection with Code Language Models: How Far Are We?cited by 139
Built on by
Not cited yet.
Similar, not cited
Close in wording, no citation either way
- 2026Which Neurons Detect Malicious Code? A Probing Study of LLM Security Knowledge
- 2024Security Vulnerability Detection with Multitask Self-Instructed Fine-Tuning of Large Language Models
- 2024Towards Explainable Vulnerability Detection with Large Language Models
- 2026Do Fine-Tuned LLMs Understand Vulnerabilities? An Investigation into the Semantic Trap
- 2026SafeSeek: Universal Attribution of Safety Circuits in Language Models
- 2024To Err is Machine: Vulnerability Detection Challenges LLM Reasoning
- 2026Neuro-Symbolic Reasoning for Vulnerability Detection
- 2026RACC: Representation-Aware Coverage Criteria for LLM Safety Testing