首个评估大模型抵抗恶意代码生成能力的基准测试
RMCBench: Benchmarking Large Language Models' Resistance to Malicious Code
- 设计473个提示,覆盖文本转代码和代码转代码两种场景
- 平均拒答率仅28.71%,顶尖模型ChatGPT-4也仅35.73%
- 揭示当前模型在对抗恶意代码生成时严重不足,适合安全研究者参考
大型语言模型(LLMs)在软件开发中影响深远,但其可能生成有害内容或被恶意开发者用于构造恶意代码,带来显著风险。尽管已有研究关注模型对违反人类伦理内容(如偏见或冒犯性内容)的抵抗能力,但尚无研究评估其对恶意代码生成的防御能力。为此,本文提出RMCBench,首个包含473个提示的基准,用于评估大模型抵抗恶意代码生成的能力。该基准涵盖两种场景:文本到代码(根据描述生成代码)与代码到代码(翻译或补全现有恶意代码)。基于RMCBench,我们对11个代表性大模型进行了实证研究。结果表明,当前模型在抵抗恶意代码生成方面能力有限:文本到代码场景下平均拒答率为40.36%,代码到代码场景为11.52%;所有模型在整体上的平均拒答率仅为28.71%,其中ChatGPT-4仅为35.73%。我们还分析了影响模型抵抗能力的因素,并为提升模型鲁棒性提供了实践建议。
原文摘要 · Abstract (English)
The emergence of Large Language Models (LLMs) has significantly influenced various aspects of software development activities. Despite their benefits, LLMs also pose notable risks, including the potential to generate harmful content and being abused by malicious developers to create malicious code. Several previous studies have focused on the ability of LLMs to resist the generation of harmful content that violates human ethical standards, such as biased or offensive content. However, there is no research evaluating the ability of LLMs to resist malicious code generation. To fill this gap, we propose RMCBench, the first benchmark comprising 473 prompts designed to assess the ability of LLMs to resist malicious code generation. This benchmark employs two scenarios: a text-to-code scenario, where LLMs are prompted with descriptions to generate code, and a code-to-code scenario, where LLMs translate or complete existing malicious code. Based on RMCBench, we conduct an empirical study on 11 representative LLMs to assess their ability to resist malicious code generation. Our findings indicate that current LLMs have a limited ability to resist malicious code generation with an average refusal rate of 40.36% in text-to-code scenario and 11.52% in code-to-code scenario. The average refusal rate of all LLMs in RMCBench is only 28.71%; ChatGPT-4 has a refusal rate of only 35.73%. We also analyze the factors that affect LLMs' ability to resist malicious code generation and provide implications for developers to enhance model robustness.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。