大模型
arxiv.org ·
引导AI修复自身缺陷:LLM驱动安全代码生成的实证研究
该研究调查了如何引导大型语言模型(LLM)在代码生成中预防和修复安全漏洞。实验表明,自我生成的漏洞提示能有效减少不安全代码,且提示的相关性和精确性影响效果;在事后修复中,原始检测工具反馈能提升所有模型的安全性,而详细可操作的解释在部分基准上带来额外提升,但对涉及多漏洞的真实任务效果不稳定。
AI推荐理由 该研究来自arXiv预印本,作者为学术研究者,提供了系统性的实证分析,信息密度高,时效性较好(2025年6月提交,2026年9月更新)。研究探讨了LLM在安全代码生成中的自我修复能力,具有实际应用价值,但属于学术研究,尚未验证实际效果。
78
正文
计算机科学 > 软件工程
arXiv:2506.23034 (cs)
[提交于2025年6月28日(v1),最后修订于2026年9月4日(本版本,v2)]
标题:引导AI修复自身缺陷:关于LLM驱动的安全代码生成的实证研究
作者:Hao Yan, Swapneel Suhas Vaidya, Xiaokuan Zhang, Ziyu Yao
查看论文PDF,标题为“引导AI修复自身缺陷:关于LLM驱动的安全代码生成的实证研究”,作者:Hao Yan等3人
查看PDF
HTML(实验性)
摘要:大型语言模型已成为编程的强大工具。然而,它们常常忽视基本的安全实践,生成带有漏洞的不安全代码。尽管存在这种风险,现有工作对引导LLM生成安全代码的指导有限,并且缺乏对LLM修复易受攻击代码有效性的系统分析。在这项工作中,我们研究了如何在代码生成过程中引导LLM预防和修复安全漏洞。具体来说,我们考察了自生成的漏洞提示是否有助于模型避免不安全代码,并评估了不同反馈水平对事后漏洞修复的影响。我们的研究考虑了多种规模的专有和开放权重模型,并使用涵盖多种漏洞类型的既定基准。我们的结果表明,自生成的漏洞提示能有效减少不安全代码,其有效性强烈依赖于相关性和精确性。我们进一步发现,更具指导性的提示(指出目标弱点,解释它如何在任务中出现,并指定如何避免)能更有效地防止易受攻击的代码。对于事后漏洞修复,原始检测工具反馈提高了所有模型的安全性,而详细、可操作的说明在三个基准中的两个上提供了进一步的改进,特别是对于指令遵循能力更强的模型。然而,对于包含触发多个弱点的真实世界任务的基准,这种解释性反馈并不始终优于原始反馈。
主题:
软件工程 (cs.SE)
引用为:
arXiv:2506.23034 [cs.SE]
(或
arXiv:2506.23034v2 [cs.SE] 用于此版本)
https://doi.org/10.48550/arXiv.2506.23034
了解更多
arXiv发布的DOI via DataCite
提交历史
来自:Hao Yan [查看电子邮件]
[v1]
2025年6月28日星期六 23:24:33 UTC (1,562 KB)
[v2]
2026年9月4日星期五 14:20:19 UTC (1,578 KB)
全文链接:
访问论文:
查看论文PDF,标题为“引导AI修复自身缺陷:关于LLM驱动的安全代码生成的实证研究”,作者:Hao Yan等3人
查看PDF
HTML(实验性)
TeX源
查看许可证
当前浏览上下文:
cs.SE
新
|
最近
| 2025-06
更改为浏览:
cs
参考文献与引用
NASA ADS
Google Scholar
Semantic Scholar
导出BibTeX引用
加载中...
BibTeX格式引用
×
加载中...
数据提供者:
书签
书目工具
书目与引用工具
书目浏览器切换
书目浏览器(什么是浏览器?)
关联论文切换
关联论文(什么是关联论文?)
Litmaps切换
Litmaps(什么是Litmaps?)
scite.ai切换
scite智能引用(什么是智能引用?)
代码、数据、媒体
与本文相关的代码、数据和媒体
alphaXiv切换
alphaXiv(什么是alphaXiv?)
代码链接切换
CatalyzeX论文代码查找器(什么是CatalyzeX?)
DagsHub切换
DagsHub(什么是DagsHub?)
GotitPub切换
Gotit.pub(什么是GotitPub?)
Huggingface切换
Hugging Face(什么是Huggingface?)
ScienceCast切换
ScienceCast(什么是ScienceCast?)
演示
演示
Replicate切换
Replicate(什么是Replicate?)
Spaces切换
Hugging Face Spaces(什么是Spaces?)
Spaces切换
TXYZ.AI(什么是TXYZ.AI?)
相关论文
推荐与搜索工具
链接到Influence Flower
Influence Flower(什么是Influence Flowers?)
核心推荐器切换
CORE推荐器(什么是CORE?)
作者
会议
机构
主题
关于arXivLabs
arXivLabs:与社区合作者的实验项目
arXivLabs是一个框架,允许合作者直接在我们的网站上开发和分享新的arXiv功能。
与arXivLabs合作的个人和组织都接受并采纳了我们的价值观:开放、社区、卓越和用户数据隐私。arXiv致力于这些价值观,并且只与遵守这些价值观的合作伙伴合作。
有一个能为arXiv社区增加价值的项目想法?了解更多关于arXivLabs的信息。
这篇论文的哪些作者是背书人?|
禁用MathJax(什么是MathJax?)
查看原文(中文正文为 AI 翻译)
Computer Science > Software Engineering
arXiv:2506.23034 (cs)
[Submitted on 28 Jun 2025 (v1), last revised 4 Sep 2026 (this version, v2)]
Title:Guiding AI to Fix Its Own Flaws: An Empirical Study on LLM-Driven Secure Code Generation
Authors:Hao Yan, Swapneel Suhas Vaidya, Xiaokuan Zhang, Ziyu Yao
View a PDF of the paper titled Guiding AI to Fix Its Own Flaws: An Empirical Study on LLM-Driven Secure Code Generation, by Hao Yan and 3 other authors
View PDF
HTML (experimental)
Abstract:Large Language Models have become powerful tools for programming. However, they often overlook essential security practices, producing insecure code with vulnerabilities. Despite this risk, existing work offers limited guidance on steering LLMs toward secure code generation and lacks systematic analysis of how effectively LLMs repair vulnerable code. In this work, we investigate how LLMs can be guided to prevent and repair security vulnerabilities during code generation. Specifically, we examine whether self-generated vulnerability hints help models avoid insecure code, and evaluate how different feedback levels influence post-hoc vulnerability repair. Our study considers proprietary and open-weight models across multiple scales and uses established benchmarks covering diverse vulnerability types. Our results show that self-generated vulnerability hints meaningfully reduce insecure code, with effectiveness depending strongly on relevance and preciseness. We further find that more directive hints, which name the target weakness, explain how it could arise in the task, and specify how to avoid it, more effectively prevent vulnerable code. For post-hoc vulnerability repair, raw detection-tool feedback improves security across all models, while detailed, actionable explanations provide further gains on two of the three benchmarks, especially for models with stronger instruction-following capabilities. Yet, this explained feedback does not consistently outperform the raw feedback for the benchmark containing real-world tasks triggering multiple weaknesses.
Subjects:
Software Engineering (cs.SE)
Cite as:
arXiv:2506.23034 [cs.SE]
(or
arXiv:2506.23034v2 [cs.SE] for this version)
https://doi.org/10.48550/arXiv.2506.23034
Focus to learn more
arXiv-issued DOI via DataCite
Submission history
From: Hao Yan [view email]
[v1]
Sat, 28 Jun 2025 23:24:33 UTC (1,562 KB)
[v2]
Fri, 4 Sep 2026 14:20:19 UTC (1,578 KB)
Full-text links:
Access Paper:
View a PDF of the paper titled Guiding AI to Fix Its Own Flaws: An Empirical Study on LLM-Driven Secure Code Generation, by Hao Yan and 3 other authors
View PDF
HTML (experimental)
TeX Source
view license
Current browse context:
cs.SE
new
|
recent
| 2025-06
Change to browse by:
cs
References & Citations
NASA ADS
Google Scholar
Semantic Scholar
export BibTeX citation
Loading...
BibTeX formatted citation
×
loading...
Data provided by:
Bookmark
Bibliographic Tools
Bibliographic and Citation Tools
Bibliographic Explorer Toggle
Bibliographic Explorer (What is the Explorer?)
Connected Papers Toggle
Connected Papers (What is Connected Papers?)
Litmaps Toggle
Litmaps (What is Litmaps?)
scite.ai Toggle
scite Smart Citations (What are Smart Citations?)
Code, Data, Media
Code, Data and Media Associated with this Article
alphaXiv Toggle
alphaXiv (What is alphaXiv?)
Links to Code Toggle
CatalyzeX Code Finder for Papers (What is CatalyzeX?)
DagsHub Toggle
DagsHub (What is DagsHub?)
GotitPub Toggle
Gotit.pub (What is GotitPub?)
Huggingface Toggle
Hugging Face (What is Huggingface?)
ScienceCast Toggle
ScienceCast (What is ScienceCast?)
Demos
Demos
Replicate Toggle
Replicate (What is Replicate?)
Spaces Toggle
Hugging Face Spaces (What is Spaces?)
Spaces Toggle
TXYZ.AI (What is TXYZ.AI?)
Related Papers
Recommenders and Search Tools
Link to Influence Flower
Influence Flower (What are Influence Flowers?)
Core recommender toggle
CORE Recommender (What is CORE?)
Author
Venue
Institution
Topic
About arXivLabs
arXivLabs: experimental projects with community collaborators
arXivLabs is a framework that allows collaborators to develop and share new arXiv features directly on our website.
Both individuals and organizations that work with arXivLabs have embraced and accepted our values of openness, community, excellence, and user data privacy. arXiv is committed to these values and only works with partners that adhere to them.
Have an idea for a project that will add value for arXiv's community? Learn more about arXivLabs.
Which authors of this paper are endorsers? |
Disable MathJax (What is MathJax?)