arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2602.10418cs.CRcs.SE
收藏

SecCodePRM: 一种用于代码安全的过程奖励模型

SecCodePRM: A Process Reward Model for Code Security

Carnegie Mellon University(卡内基梅隆大学);Colorado State University(科罗拉多州立大学);University of California, Berkeley(加州大学伯克利分校)

Weichen Yu, Ravi Mangal, Yinyi Luo, Kai Hu, Jingxuan He, Corina S. Pasareanu, Matt Fredrikson

AI总结:

SecCodePRM通过一种面向安全的过程奖励模型,提升代码安全性和检测效率,适用于完整代码漏洞检测、部分代码漏洞检测和安全代码生成。

摘要:

大型语言模型正迅速成为现代软件开发工作流中的核心组件,但确保代码安全仍然具有挑战性。现有的漏洞检测流水线要么依赖静态分析器,要么使用基于LLM/GNN的检测器,这些检测器通过粗粒度的程序级监督进行训练。这两种方法往往需要完整的上下文,提供稀疏的结束反馈,并且随着代码长度的增长而退化,使其不适合在交互式编程和流式生成过程中进行实时、前缀级评估。我们提出了SecCodePRM,一种面向安全的过程奖励模型,它能够沿着代码轨迹分配一个上下文感知、分步的安全评分。为了训练该模型,我们从静态分析器和专家注释中推导出分步监督标签,使模型能够更精确地关注与跨过程漏洞相关的细粒度区域。SecCodePRM有三种应用:完整代码漏洞检测(VD)、部分代码漏洞检测和安全代码生成(CG)。对于VD,SecCodePRM使用风险敏感的聚合,强调高风险步骤;对于CG,SecCodePRM通过对候选延续进行排名并在选择时优先考虑更高的累积奖励来支持推理时的扩展。这种设计产生了密集的、实时的反馈,能够扩展到长时间范围的生成。实证结果表明,SecCodePRM在所有三个设置中均优于先前的方法,同时保持代码功能正确性,表明在不牺牲安全性的情况下,安全性能得到了提升。

英文摘要:

Large Language Models are rapidly becoming core components of modern software development workflows, yet ensuring code security remains challenging. Existing vulnerability detection pipelines either rely on static analyzers or use LLM/GNN-based detectors trained with coarse program-level supervision. Both families often require complete context, provide sparse end-of-completion feedback, and can degrade as code length grows, making them ill-suited for real-time, prefix-level assessment during interactive coding and streaming generation. We propose SecCodePRM, a security-oriented process reward model that assigns a context-aware, step-level security score along a code trajectory. To train the model, we derive step-level supervision labels from static analyzers and expert annotations, allowing the model to attend more precisely to fine-grained regions associated with inter-procedural vulnerabilities. SecCodePRM has three applications: full-code vulnerability detection (VD), partial-code VD, and secure code generation (CG). For VD, SecCodePRM uses risk-sensitive aggregation that emphasizes high-risk steps; for CG, SecCodePRM supports inference-time scaling by ranking candidate continuations and favoring higher cumulative reward. This design yields dense, real-time feedback that scales to long-horizon generation. Empirically, SecCodePRM outperforms prior approaches in all three settings, while preserving code functional correctness, suggesting improved security without a safety-utility tradeoff.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑