GoodVibe: Security-by-Vibe for LLM-Based Code Generation

Maximilian Thang, Technical University of Darmstadt; Lichao Wu, University of Bristol; Sasha Behrouzi and Mohamadreza Rostami, Technical University of Darmstadt; Jona te Lintelo, Radboud University; Stjepan Picek, University of Zagreb and Radboud University; Ahmad-Reza Sadeghi, Technical University of Darmstadt

Large language models (LLMs) are increasingly used for code generation in fast, informal development workflows, often referred to as vibe coding, where speed and convenience are prioritized, and security requirements are rarely made explicit. In this setting, models frequently produce functionally correct but insecure code, creating a growing security risk. Existing approaches to improving code security rely on full-parameter fine-tuning or parameter-efficient adaptations, which are either costly and prone to catastrophic forgetting or operate at coarse granularity with limited interpretability and control. We present GoodVibe, a neuron-level framework for improving the security of code language models by default. GoodVibe is based on the key insight that security-relevant reasoning is localized to a small subset of neurons. We identify these neurons using gradient-based attribution from a supervised security task and perform neuron-selective fine-tuning that updates only this security-critical subspace. To further reduce training cost, we introduce activation-driven neuron clustering, enabling structured updates with minimal overhead. We evaluate GoodVibe on six LLMs across security-critical programming languages, including C++, Java, Swift, and Go. GoodVibe substantially improves the security of generated code while preserving general model utility, achieving up to a 2.5× improvement over base models, achieving performance competitive with full fine-tuning while using over 4700× fewer trainable parameters, and reducing training computation by more than 3.6× compared to the parameter-efficient baseline (LoRA). Our results demonstrate that neuron-level optimization offers an effective and scalable approach to securing code generation without sacrificing generality.

USENIX Security '26 Open Access Sponsored by
King Abdullah University of Science and Technology (KAUST)

Open Access Media

USENIX is committed to Open Access to the research presented at our events. Papers and proceedings are freely available to everyone once the event begins. Any video, audio, and/or slides that are posted after the event are also free and open to everyone. Support USENIX and our commitment to Open Access.

BibTeX
@inproceedings {320693,
author = {Maximilian Thang and Lichao Wu and Sasha Behrouzi and Mohamadreza Rostami and Jona te Lintelo and Stjepan Picek and Ahmad-Reza Sadeghi},
title = {{GoodVibe}: {Security-by-Vibe} for {LLM-Based} Code Generation},
booktitle = {35th USENIX Security Symposium (USENIX Security 26)},
year = {2026},
isbn = {978-1-939133-58-8},
address = {Baltimore, MD},
pages = {4425--4442},
url = {https://www.usenix.org/conference/usenixsecurity26/presentation/thang},
publisher = {USENIX Association},
month = aug
}