CORTEXA
← Browse
arxivcs.SEcs.CRcs.LG2026-07-08

Functional and Secure Code Generation with Task Vectors

Felix Wang, Anudeep Das, Mei Nagappan, N. Asokan

Large language models (LLMs) are increasingly used for code generation, but they struggle to generate functional code free of security vulnerabilities. Prior work to improve the secure code generation abilities of such coding LLMs has largely focused on evaluating code functionality and security separately using different datasets, or focused on finding vulnerabilities post-generation. At the same time, the text-generation domain has seen significant work on alignment techniques, where models are tuned such that their outputs exhibit certain qualities (e.g., helpfulness, harmlessness). Of particular interest is task-vector arithmetic, where linear operations on LLM weights can be used to arbitrarily enhance alignment while incurring only minimal computational overhead. We develop a novel method, SecVecCoder, leveraging task vectors to produce trustworthy code that is simultaneously functional and secure without the need for post-generation adjustment. Across six coding LLMs from three families on the CodeGuard+ benchmark, SecVecCoder improves the rate of trustworthy code completions by 2.1-36.0 percentage points over the base model, with improvements on unseen CWE types reaching up to 39.1 percentage points. Since the effectiveness of the coding LLM relies only on changing the model weights, SecVecCoder requires no method-specific decoding and hence achieves a decoding latency within 0.6% of the base model's, on average.

View free PDFSource page

Related papers

arxivcs.SEcs.CRcs.LG2026-06-30

An Empirical Study of Security Calibration in Large Language Models for Code

Mohammed Latif Siddiq, Md. Nafiu Rahman, Joanna C. S. Santos

Large Language Models (LLMs) are rapidly transforming software development, yet their use in security-critical contexts raises a key question: do models know when their generated code is insecure? This property, known as calibration, measures whether a model's confidence aligns w…

View free PDFSource page
arxivcs.SEcs.AIcs.CRcs.IRcs.LG2026-07-18

How Do You Choose Your AI Component? An Interview Study of Secure AI Integration in Practice

Mahzabin Tamanna, Elizabeth Lin, Sparsha Gowda, Laurie Williams, Dominik Wermke

The increasing adoption of Large Language Models (LLMs) as AI components in modern software systems introduces distinct security risks to the software supply chain. While many considerations and safety mechanisms are in place for components of the traditional software supply chai…

View free PDFSource page
arxivcs.LGcs.SE2026-07-06

Beyond the Need for Speed: Energy-Aware Code Generation via Simulation-Guided Reinforcement Learning

Saurabhsingh Rajput, Tushar Sharma

Code models strictly prioritize functional correctness, leaving software energy efficiency as an unoptimized byproduct. Training models to generate energy-efficient code requires reproducible feedback at scale, which physical hardware measurement cannot reliably provide due to va…

View free PDFSource page
arxivcs.SEcs.LGcs.PL2026-07-15

Quantize with Confidence? An Empirical Study of Quantization for Code Generation

Saima Afrin, Md. Zahidul Haque, Antonio Mastropaolo

The growing adoption of local inference frameworks such as Ollama has made it increasingly common for developers to run large code models on laptops and other resource-constrained hardware. In these settings, post-training quantization is essential for reducing memory footprint a…

View free PDFSource page
arxivcs.LGcs.SE2026-07-21

Spaghetti Architect: A Contamination-Resistant, By-Construction-Labelled, Multi-Language Code Dataset Generator

Yuxiang Ji

Mined code corpora are abundant but uncontrolled: a snippet's semantics, surface "messiness," and difficulty are whatever the wild contained; there is no known-optimal reference to grade against; and any public sample may already sit in a model's training set. We present Spaghett…

View free PDFSource page