Proceedings of the ACM on software engineering.Open accessComputer science

Understanding and Improving Model Editing for Secure Code Generation

Weifeng Sun, Quanjun Zhang, Yuchen Chen, Chengran Yang, Gou Tan, David Lo

Singapore Management University · Nanjing University of Science and Technology

Key points

From the paper's conclusion
  • 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.
  • Model editing substantially outperforms CoSec on seen vulnerabilities, improving security ratios by 15.

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 the paper

Discussion · 1

Science Skim's AI key points, plus readers' public thoughts

Science SkimAI key points
Pinned
  • 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.
  • Model editing substantially outperforms CoSec on seen vulnerabilities, improving security ratios by 15.

Readers' thoughts

No reader thoughts yet.

Related papers