大语言模型应用于软件渗透测试的初步研究
A Preliminary Study on Using Large Language Models in Software Pentesting
AI总结:
该研究针对软件渗透测试的漏洞自动识别需求,提出通过提示词工程优化基于LLM的AI智能体性能的思路,经OWASP Benchmark数据集验证,证实该方案具备可行性。
摘要:
大语言模型(LLM)被认为在安全任务自动化方面具备可观潜力,例如安全运营中心(SOC)中的各类任务。作为评估这一预期潜力的第一步,我们探究了LLM在软件渗透测试中的应用,该领域的核心任务是自动识别源代码中的软件安全漏洞。我们提出假设:基于LLM的AI智能体在执行特定安全任务时,可随着人类操作员的交互逐步提升性能。作为实现这一提升的初步路径,可根据模型生成的响应对输入LLM的提示词进行工程优化,加入相关上下文与结构,从而让模型输出更准确的结果。如果针对当前任务优化后能提升效果的提示词,也能在未来未知任务上取得更好表现,那么这类工程工作就具备可持续性。为验证该假设,我们使用了包含2740个手工构建、覆盖多种漏洞类型的源代码测试用例的OWASP Benchmark Project 1.2数据集。我们将测试用例划分为训练集和测试集,仅基于训练集开展提示词工程优化,最终在测试集上评估系统性能。我们对比了经提示词工程优化的AI智能体与未做优化的智能体在测试集上的表现,还将AI智能体的结果与广泛应用于安全测试的静态代码分析工具SonarQube的结果做了对比。我们使用多款现成LLM构建并测试了多个版本的AI智能体,包括谷歌的Gemini-pro,以及OpenAI的GPT-3.5-Turbo和GPT-4-Turbo(同时使用聊天补全和助手API)。结果表明,利用LLM构建可通过重复使用与提示词工程持续优化的软件渗透测试AI智能体,是一种可行的方案。
英文摘要:
Large language models (LLM) are perceived to offer promising potentials for automating security tasks, such as those found in security operation centers (SOCs). As a first step towards evaluating this perceived potential, we investigate the use of LLMs in software pentesting, where the main task is to automatically identify software security vulnerabilities in source code. We hypothesize that an LLM-based AI agent can be improved over time for a specific security task as human operators interact with it. Such improvement can be made, as a first step, by engineering prompts fed to the LLM based on the responses produced, to include relevant contexts and structures so that the model provides more accurate results. Such engineering efforts become sustainable if the prompts that are engineered to produce better results on current tasks, also produce better results on future unknown tasks. To examine this hypothesis, we utilize the OWASP Benchmark Project 1.2 which contains 2,740 hand-crafted source code test cases containing various types of vulnerabilities. We divide the test cases into training and testing data, where we engineer the prompts based on the training data (only), and evaluate the final system on the testing data. We compare the AI agent's performance on the testing data against the performance of the agent without the prompt engineering. We also compare the AI agent's results against those from SonarQube, a widely used static code analyzer for security testing. We built and tested multiple versions of the AI agent using different off-the-shelf LLMs -- Google's Gemini-pro, as well as OpenAI's GPT-3.5-Turbo and GPT-4-Turbo (with both chat completion and assistant APIs). The results show that using LLMs is a viable approach to build an AI agent for software pentesting that can improve through repeated use and prompt engineering.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。