CRMay 29

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

arXiv:2602.1077891.51 citationsh-index: 40
AI Analysis

This work offers a more efficient and scalable method for improving the security of code generated by LLMs, which is a growing concern for developers and organizations using these models in informal settings.

This paper addresses the generation of insecure code by LLMs in rapid development workflows. The authors propose GoodVibe, a neuron-level fine-tuning framework that identifies and updates a small subset of security-critical neurons, achieving up to a 2.5x improvement in code security over base models. GoodVibe performs comparably to full fine-tuning while using 4,700x fewer trainable parameters and reducing training computation by over 3.6x compared to LoRA.

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.5x improvement over base models, achieving performance competitive with full fine-tuning while using over 4,700x fewer trainable parameters, and reducing training computation by more than 3.6x 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.

Foundations

The foundational work for this paper's niche, ranked by how specifically the neighbourhood builds on it — not by global fame.

Your Notes