APILOT:引导大型语言模型避开过时API陷阱以生成安全代码
APILOT: Navigating Large Language Models to Generate Secure Code by Sidestepping Outdated API Pitfalls
AI总结:
针对LLMs因更新成本高而易推荐含过时API的不安全代码问题,提出APILOT方案,通过维护实时过时API数据集并利用增强生成方法引导模型生成安全代码,在7个模型上平均减少89.42%过时推荐并提升27.54%可用性。
摘要:
随着大型语言模型(LLMs)的快速发展,其应用已扩展到代码辅助等各个领域。然而,LLMs的庞大规模使其训练极其耗费资源和时间,导致频繁的重新训练或更新变得不切实际。因此,时效性敏感的数据可能会过时,从而在时间感知任务中误导LLMs。例如,每天都有各种程序被发现新的漏洞。如果不更新知识,LLMs可能会无意中生成包含这些新发现漏洞的代码。当前的策略,如提示工程和微调,无法有效解决这一问题。为了解决这一问题,我们提出了一种名为APILOT的解决方案,它维护着一个实时、可快速更新的过时API数据集。此外,APILOT利用一种增强生成方法,借助该数据集引导LLMs生成安全的、版本感知的代码。我们进行了全面的评估,以衡量APILOT在减少七个不同的最先进LLMs中过时API推荐发生率方面的有效性。评估结果表明,APILOT在有限的性能开销下,平均能减少89.42%的过时代码推荐。有趣的是,在增强安全性的同时,APILOT还提高了LLMs生成代码的可用性,可用性平均提升了27.54%。这突显了APILOT在当代软件开发环境中同时提升代码建议安全性和实用效用的双重能力。
英文摘要:
With the rapid development of large language models (LLMs), their applications have expanded into diverse fields, such as code assistance. However, the substantial size of LLMs makes their training highly resource- and time-intensive, rendering frequent retraining or updates impractical. Consequently, time-sensitive data can become outdated, potentially misleading LLMs in time-aware tasks. For example, new vulnerabilities are discovered in various programs every day. Without updating their knowledge, LLMs may inadvertently generate code that includes these newly discovered vulnerabilities. Current strategies, such as prompt engineering and fine-tuning, do not effectively address this issue. To address this issue, we propose solution, named APILOT, which maintains a realtime, quickly updatable dataset of outdated APIs. Additionally, APILOT utilizes an augmented generation method that leverages this dataset to navigate LLMs in generating secure, version-aware code. We conducted a comprehensive evaluation to measure the effectiveness of APILOT in reducing the incidence of outdated API recommendations across seven different state-of-the-art LLMs. The evaluation results indicate that APILOT can reduce outdated code recommendations by 89.42% on average with limited performance overhead. Interestingly, while enhancing security, APILOT also improves the usability of the code generated by LLMs, showing an average increase of 27.54% in usability. This underscores APILOT's dual capability to enhance both the safety and practical utility of code suggestions in contemporary software development environments.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。