Amplifying certain FFN neurons improves LLM malware detection accuracy, but effects vary by model
Specific feed-forward neurons encode malware-detection behavior and can be edited to increase detection accuracy
Software arXiv 11 Jul 2026 Measurement Prototype evidence
Published as “Which Neurons Detect Malicious Code? A Probing Study of LLM Security Knowledge”
Why it matters
The ability to edit or suppress specific neurons enables lightweight early-exit safety checks and targeted model editing to improve code-LLM defenses without retraining.
Summary
Neuron-level probing reveals that malicious-code detection in code LLMs is encoded in specific feed-forward neurons, but the effect of editing those neurons varies widely across models. Amplifying facilitating neurons and suppressing inhibiting ones boosts Mistralv0.3-7B-Instruct accuracy from 66.5% to 94.1%, while high-baseline models (Llama3.1-8B-Instruct, Qwen2.5-7B-Instruct) show negligible gains and collapse to 50% when good neurons are suppressed. The defensive neurons cluster in middle layers for Llama and Mistral and in late layers for Qwen, and their layer-level distribution is stable even though individual neuron selection is not.
What they found 3
- Mistralv0.3-7B-Instruct accuracy rises from 66.5% to 94.1% when facilitating neurons are amplified (IG Enhancer).
“Mistralv0.3-7B-Instruct improves from 66.5% to 94.1% under the IG Enhancer.”
- Llama3.1-8B-Instruct collapses to chance level (50.0%) when identified good neurons are suppressed.
“the former collapses to 50.0% under the Degrader (both methods)”
- Integrated Gradients yields equal or larger effectiveness gaps than Neuron Conductance across all models.
“Overall, IG achieves larger or equal effectiveness gaps compared to NC.”
Caveats 3
- the high-baseline models Llama3.1-8B-Instruct and Qwen2.5-7B-Instruct (93.9%) show little response to corrective interventions (Suppress Bad, Enhancer)
- Attribution identifies a layer-level signal that is stable across seeds, but the specific neurons selected are not: pairwise Jaccard similarity remains below 0.20 (Fig. 4). Our conclusions, therefore, hold at the granularity of layer bands rather than at the level of individual neurons.
- Our findings are derived exclusively from three 7-8B LLMs and Python/PyPI packages, focusing on install-time and import-time payloads. They may not transfer to larger or differently aligned models, to other ecosystems (e.g., npm, Maven) or attack vectors (e.g., typosquatting), or to malware more recent than the PyPI Malregistry [8].
What’s new here 4
- Identifies specific FFN neurons responsible for malware detection in code-focused LLMs.
- Demonstrates causal intervention (amplify/suppress neurons) can dramatically improve or degrade detection accuracy.
- Shows model-dependent layer localization of defensive neurons, enabling early-exit safety checks.
- Provides open-source replication package for neuron attribution and intervention on code LLMs.