mlsanityData to 14 Oct 2026

Which Neurons Detect Malicious Code? A Probing Study of LLM Security Knowledge

arXiv 2607.10221 ↗First posted 11 Jul 2026cs.SE cs.CRcited by 0

On the map: LLM safety and security → Jailbreaking

Abstract (arXiv)

Background. Large language models (LLMs) have become increasingly capable of understanding and generating source code, leading to their widespread adoption in software engineering tasks such as code completion, repair, and vulnerability detection. However, despite their strong empirical performance, the internal mechanisms through which LLMs recognize malicious or vulnerable code patterns remain poorly understood. Aim. We investigated where the malware detection behavior is encoded inside LLMs Feed Forward Network (FFN) neurons and verified the attribution with causal interventions on the neurons identified. This aims to identify the most important neurons in detecting malicious code. Methods. We applied mechanistic interpretability methods to locate the neurons being responsible for malware-detection behavior in three instruction-tuned LLMs: Llama3.1-8B-Instruct, Mistral-v0.3-7B-Instruct, and Qwen2.5-7B-Instruct. Using 1,500 malicious and 1,500 benign PyPI packages from the PyPI Malregistry, we attribute the behavior to a set of neurons. Results. The experimental results reveal that amplifying facilitating neurons for malware detection while suppressing inhibiting ones can boost accuracy, while the reverse collapses predictions toward a single class, although the magnitude and consistency is heavily model-dependent. We demonstrated that the guardrail detection mechanism varies across models, each represents its malware detection behavior differently within its FFN layers. Conclusions. Probing the neurons associated with security-relevant knowledge helps us gain insights into how LLMs encode malicious programming concepts, identify potentially harmful memorized behaviors, paving the way toward more reliable defense mechanisms, such as neuron-level editing, selective unlearning, and security-aware alignment for code-focused LLMs.

Key facts. No citing papers in the map yet (data through 14 Oct 2026). Placed in Jailbreaking, one of 12 directions in LLM safety and security. Builds on 15 of its 24 references that are in the map. First posted on arXiv 11 Jul 2026.

Builds on

15 of 24 references.

Closest ancestors · 1

Same direction, newest first

  1. 2023Universal and Transferable Adversarial Attacks on Aligned Language Models27 Jul

Other references · 14

  1. 2021Evaluating Large Language Models Trained on Codecited by 8,320
  2. 2017Axiomatic Attribution for Deep Networkscited by 3,384
  3. 2020Extracting Training Data from Large Language Modelscited by 2,189
  4. 2022Red Teaming Language Models with Language Modelscited by 1,026
  5. 2019Universal Adversarial Triggers for Attacking and Analyzing NLPcited by 722
  6. 2023Large Language Models Are Not Robust Multiple Choice Selectorscited by 486
  7. 2023Scalable Extraction of Training Data from (Production) Language Modelscited by 434
  8. 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 431
  9. 2023Large Language Models Sensitivity to The Order of Options in Multiple-Choice Questionscited by 263
  10. 2022Natural Attack for Pre-trained Models of Codecited by 75
  11. 2023Stealthy Backdoor Attack for Code Modelscited by 49
  12. 2023An Empirical Study of Malicious Code In PyPI Ecosystemcited by 19
2 more
  1. 2025Explicit Vulnerability Generation with LLMs: An Investigation Beyond Adversarial Attackscited by 2
  2. 2026Identifying Good and Bad Neurons for Task-Level Controllable LLMscited by 1

Built on by

Not cited yet.

Similar, not cited

Close in wording, no citation either way

  1. 2026Dissecting the Black Box: Circuit-Level Analysis of LLM Vulnerability Detection
  2. 2025Unraveling LLM Jailbreaks Through Safety Knowledge Neurons
  3. 2024Measuring Impacts of Poisoning on Model Parameters and Neuron Activations: A Case Study of Poisoning CodeBERT
  4. 2025"Digital Camouflage": The LLVM Challenge in LLM-Based Malware Detection
  5. 2026Defense Against LLM Backdoors using Critical Neuron Isolation Pruning
  6. 2026NeuronFuzz: Safety Neuron Guided Fuzzing for LLM Safety Evaluation
  7. 2024Security Vulnerability Detection with Multitask Self-Instructed Fine-Tuning of Large Language Models
  8. 2026Circuit Discovery Helps Detect LLM Jailbreaking: A Mechanistic Interpretability Study