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.


翻译:大语言模型正迅速成为现代软件开发流程的核心组成部分,然而确保代码安全仍然具有挑战性。现有的漏洞检测流程要么依赖于静态分析器,要么使用基于LLM/GNN的检测器,这些检测器仅接受粗粒度的程序级监督进行训练。这两类方法通常需要完整的代码上下文,仅提供稀疏的完成时反馈,并且可能随着代码长度的增加而性能下降,因此不适合在交互式编码和流式生成过程中进行实时、前缀级别的评估。我们提出了SecCodePRM,一种面向安全的过程奖励模型,它能够沿着代码轨迹分配具有上下文感知的步骤级安全分数。为了训练该模型,我们从静态分析器和专家标注中推导出步骤级监督标签,使模型能够更精确地关注与过程间漏洞相关的细粒度区域。SecCodePRM具有三种应用场景:完整代码漏洞检测、部分代码漏洞检测以及安全代码生成。对于漏洞检测,SecCodePRM采用强调高风险步骤的风险敏感聚合策略;对于代码生成,SecCodePRM通过排序候选续写并偏好更高累积奖励的方式支持推理时缩放。这种设计产生了密集的实时反馈,并能扩展到长序列生成。实验表明,SecCodePRM在所有三种场景下均优于先前的方法,同时保持了代码功能正确性,这表明其在没有安全-效用权衡的前提下实现了安全性的提升。

0
下载
关闭预览

相关内容

代码(Code)是专知网的一个重要知识资料文档板块,旨在整理收录论文源代码、复现代码,经典工程代码等,便于用户查阅下载使用。
探索大型语言模型在网络安全中的作用:一项系统综述
专知会员服务
21+阅读 · 2025年4月27日
158页!天大等最新《大型语言模型安全:全面综述》
专知会员服务
49+阅读 · 2024年12月24日
大型语言模型代理的安全与隐私综述
专知会员服务
30+阅读 · 2024年8月5日
《大型语言模型代码生成》综述
专知会员服务
70+阅读 · 2024年6月4日
大型语言模型网络安全综述
专知会员服务
68+阅读 · 2024年5月12日
从 Encoder 到 Decoder 实现 Seq2Seq 模型
AI研习社
10+阅读 · 2018年2月10日
国家自然科学基金
4+阅读 · 2017年12月31日
国家自然科学基金
6+阅读 · 2017年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
VIP会员
最新内容
2025年大语言模型进展报告
专知会员服务
1+阅读 · 今天13:30
多智能体协作机制
专知会员服务
1+阅读 · 今天13:26
非对称优势:美海军开发低成本反无人机技术
专知会员服务
4+阅读 · 今天4:39
《美战争部小企业创新研究(SBIR)计划》
专知会员服务
6+阅读 · 今天2:48
《军事模拟:将军事条令与目标融入AI智能体》
专知会员服务
9+阅读 · 今天2:43
【NTU博士论文】3D人体动作生成
专知会员服务
7+阅读 · 4月24日
以色列军事技术对美国军力发展的持续性赋能
专知会员服务
8+阅读 · 4月24日
《深度强化学习在兵棋推演中的应用》40页报告
专知会员服务
14+阅读 · 4月24日
《多域作战面临复杂现实》
专知会员服务
10+阅读 · 4月24日
《印度的多域作战:条令与能力发展》报告
专知会员服务
5+阅读 · 4月24日
相关基金
国家自然科学基金
4+阅读 · 2017年12月31日
国家自然科学基金
6+阅读 · 2017年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员