Skip to content
Preprint Open access

Understanding and Improving Model Editing for Secure Code Generation

Aug 2026 · Vol 3, pp. 3728 - 3750 · 0 citations · 63 references
Computer Science

TL;DR

The first systematic study of model editing as a model-level hardening mechanism for secure code generation is conducted, evaluating 3 state-of-the-art editing methods across diverse LLM families and comparing them with CoSec, a representative inference-time approach, focusing on security, robustness, generalization, and functional correctness.

Abstract

Large language models (LLMs) are widely used for code generation but may reproduce vulnerabilities learned from insecure training data. Prior work mainly relies on inference-time hardening, which introduces auxiliary components and runtime overhead. We present the first systematic study of model editing as a model-level hardening mechanism for secure code generation, directly injecting security knowledge through localized parameter updates. We evaluate three state-of-the-art editing methods across diverse LLM families against CoSec, a representative inference-time approach, examining security effectiveness and robustness, generalization to unseen vulnerabilities, and functional correctness. Model editing substantially outperforms CoSec on seen vulnerabilities, improving security ratios by 15

Read PDF

Similar papers

Preprint Jul 2026

Functional and Secure Code Generation with Task Vectors

A novel method is developed, SecVecCoder, leveraging task vectors to produce trustworthy code that is simultaneously functional and secure without the need for post-generation adjustment, and achieves a decoding latency within 0.6% of the base model's, on average.

F. Wang, Anudeep Das, M. Nagappan et al. · 0 citations
Conference Open access 2026

AutoSUIT Bench - Automated Security UnIt Test Benchmark for LLM Coding

Upon benchmarking against LLMs, it is found that functionality pass rate is consistently higher than vulnerability pass rate for all programming languages, highlighting the necessity of vulnerable code benchmarks with larger CWE coverage.

Samuel Osebe, Fan Yang, Junyi Li et al. · 0 citations

Enhancing Code Model Robustness Against Identifier Renaming via Unified Code Normalization

UniCode, a novel two-stage defense framework against identifier renaming, is proposed, one of the most effective modifications influencing DCMs’ robustness, and effectively aligns the distributions between the training data and the adversarial test samples, thereby significantly enhancing model robustness.

Jia-Jun Jiang, Song-Rui Li, Han-Mo You et al. · 0 citations
Conference Open access 2026

Large Language Model Vulnerabilities

: Large language models are increasingly being deployed in safety-critical domains, yet remain vulnerable to jailbreak attacks that circumvent safety alignments. This systematic review synthesizes empirical jailbreak research published between 2024 and 2025, using a PRISMA-guided search protocol, followed by BERTopic-b...

Meda Račaitytė, Hélder Bastos, R. Ribeiro et al. · 0 citations
#small language model Preprint Aug 2026

Vulnerable Code Search: Transferable Attack for Code Language Models

This paper introduces a programming language-agnostic, transferable, adversarial attack that exploits this CLM vulnerability and demonstrates that this attack, even when computed using smaller code embedding models, is highly effective and transferable to larger, closed-source embedding models.

Kaicheng Wang, Li-Yan Huang, Jesse Thomason et al. · 0 citations
Jul 2026

The Language of Security: How Prompt Syntax Shapes Secure Code Generation in Open LLMs

This work systematically generates syntactic variants of security-relevant code generation prompts and evaluates their impact on code security across multiple open LLMs and programming languages, identifying prompt syntax as a concrete security control surface and providing actionable guidance for reducing vulnerabilit...

Matteo Cicalese, Antonio Della Porta, Stefano Lambiase et al. · 0 citations

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.