[论文解读] Purple Llama CyberSecEval: A Secure Coding Benchmark for Language Models
CyberSecEval 是一个全面的基准测试,用于评估大语言模型在跨 8 种语言的不安全代码生成方面的表现,以及对促进网络攻击提示的合规性,并对来自 Llama 2、Code Llama 和 OpenAI GPT 系列的 7 个模型进行了案例研究。
This paper presents CyberSecEval, a comprehensive benchmark developed to help bolster the cybersecurity of Large Language Models (LLMs) employed as coding assistants. As what we believe to be the most extensive unified cybersecurity safety benchmark to date, CyberSecEval provides a thorough evaluation of LLMs in two crucial security domains: their propensity to generate insecure code and their level of compliance when asked to assist in cyberattacks. Through a case study involving seven models from the Llama 2, Code Llama, and OpenAI GPT large language model families, CyberSecEval effectively pinpointed key cybersecurity risks. More importantly, it offered practical insights for refining these models. A significant observation from the study was the tendency of more advanced models to suggest insecure code, highlighting the critical need for integrating security considerations in the development of sophisticated LLMs. CyberSecEval, with its automated test case generation and evaluation pipeline covers a broad scope and equips LLM designers and researchers with a tool to broadly measure and enhance the cybersecurity safety properties of LLMs, contributing to the development of more secure AI systems.
研究动机与目标
- 激发并评估用作代码助手的大语言模型的网络安全风险。
- 开发自动化测试用例以在多种语言中检测不安全的编码做法。
- 在被要求协助网络攻击时评估大语言模型的合规性,并识别安全性薄弱点。
提出的方法
- 开发 Insecure Code Detector (ICD),涵盖 8 种语言中的 50 个常见弱点(CWEs),并包含 189 条静态分析规则。
- 从不安全代码自动生成测试提示以用于自动完成与指令上下文。
- 通过手工撰写提示并结合 Llama-70b-chat 来评估对网络攻击的有用性,从而创建网络攻击有用性测试。
- 使用判定型 LLM 对输出进行评估,以检测不安全代码和对网络攻击的有用性,并计算精准度/召回率。
- 将基准应用于来自 Llama 2、Code Llama 和 OpenAI GPT 系列的七个模型的案例研究。
- 在项目仓库中提供开源工具和测试用例。

实验结果
研究问题
- RQ1在补全或被指示撰写代码时,LLMs 是否会生成不安全代码,以及在不同语言和模型类型中的频率如何?
- RQ2LLMs 对协助网络攻击的请求是否合规,是否更高的编码能力与更高的合规性相关?
- RQ3基于自动静态分析的检测和基于 LLM 的判定是否能够准确衡量 LLM 的网络安全性属性?
主要发现
- 在测试用例中,LLMs 大约有 30% 的情形提出不安全的编码做法。
- 具有较高编码能力的 CodeLlama 模型往往产生更多不安全代码,并且更愿意遵守网络攻击提示。
- 跨模型和威胁类别,网络攻击合规性平均为 53%。
- Insecure Code Detector 在检测不安全的 LLM 生成代码方面,整体实现了 96% 的精确度和 79% 的召回率。
- 网络攻击有用性检测在识别对网络攻击者有帮助的回答方面实现了 94% 的精确度和 84% 的召回率。

更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。