Skip to main content
QUICK REVIEW

[论文解读] Using ChatGPT as a Static Application Security Testing Tool

Atieh Bakhshandeh, Abdalsamad Keramatfar|arXiv (Cornell University)|Aug 28, 2023
Software Engineering Research被引用 5
一句话总结

本文评估了通过 ChatGPT 使用提示工程将 GPT-3.5 作为 Python 代码的静态应用安全测试(SAST)工具检测漏洞的能力。结果表明,与 Bandit、Semgrep 和 SonarQube 相比,ChatGPT 显著降低了误报和漏报率,显示出作为补充 SAST 助手的强大潜力,特定配置下的 F1 分数最高达 0.4101。

ABSTRACT

In recent years, artificial intelligence has had a conspicuous growth in almost every aspect of life. One of the most applicable areas is security code review, in which a lot of AI-based tools and approaches have been proposed. Recently, ChatGPT has caught a huge amount of attention with its remarkable performance in following instructions and providing a detailed response. Regarding the similarities between natural language and code, in this paper, we study the feasibility of using ChatGPT for vulnerability detection in Python source code. Toward this goal, we feed an appropriate prompt along with vulnerable data to ChatGPT and compare its results on two datasets with the results of three widely used Static Application Security Testing tools (Bandit, Semgrep and SonarQube). We implement different kinds of experiments with ChatGPT and the results indicate that ChatGPT reduces the false positive and false negative rates and has the potential to be used for Python source code vulnerability detection.

研究动机与目标

  • 评估使用大型语言模型(特别是 ChatGPT)检测 Python 代码中软件漏洞的可行性。
  • 将 ChatGPT 的性能与成熟的 SAST 工具——Bandit、Semgrep 和 SonarQube——在漏洞检测准确率方面进行比较。
  • 调查使用 ChatGPT 进行提示工程是否能降低静态代码分析中的误报率和漏报率。
  • 探索使用 GPT-3.5 作为补充助手以提升传统 SAST 工具结果的潜力。

提出的方法

  • 本研究使用提示工程,指导 ChatGPT 基于通用弱点枚举(CWE)类别分析 Python 源代码中的安全漏洞。
  • 设计了四种不同的实验设置:二分类、漏洞列表选择、SAST 助手角色和自由文本分类。
  • 在包含已知漏洞的三个数据集上评估 ChatGPT,使用精确率、召回率和 F1 指标与 Bandit、Semgrep 和 SonarQube 进行对比。
  • 提示设计强调自然性和表达力,以提升模型性能,依据先前大型语言模型提示评估研究的指导原则。
  • 使用漏洞数据集的真实标签计算评估指标,结果在不同提示配置下进行分析。
  • 实验仅聚焦于 Python 代码,利用该语言在安全关键应用中的流行度和普遍性。
Figure 1 : F1-score of top 6 CWE classes in experiment 3 (case 2)
Figure 1 : F1-score of top 6 CWE classes in experiment 3 (case 2)

实验结果

研究问题

  • RQ1ChatGPT 是否能通过基于提示的指令有效检测 Python 源代码中的安全漏洞?
  • RQ2在精确率、召回率和 F1 分数方面,ChatGPT 的漏洞检测性能与传统 SAST 工具(如 Bandit、Semgrep 和 SonarQube)相比如何?
  • RQ3将 ChatGPT 用作 SAST 助手是否能通过降低误报和漏报率来提高现有 SAST 工具的准确性?
  • RQ4不同提示配置如何影响 ChatGPT 漏洞检测结果的可靠性和一致性?

主要发现

  • 在 SAST 助手角色中,ChatGPT 的 F1 得分为 0.1808,优于 SonarQube(F1:0.0743)、Bandit(F1:0.1022)和 Semgrep(F1:0.1812)在同一设置下的表现。
  • 在自由文本分类任务中,ChatGPT 的 F1 得分为 0.1808,表明其表现中等但具有竞争力,与基于规则的 SAST 工具相当。
  • 在二分类实验中,ChatGPT 的 F1 得分为 0.4101,显著优于 Semgrep(F1:0.1812)、Bandit(F1:0.1022)和 SonarQube(F1:0.0743)。
  • 在多个实验中,ChatGPT 的误报率和漏报率均低于所有三种基线 SAST 工具,尤其在二分类设置中表现更优。
  • 模型性能对提示设计敏感,优化后的提示显著提升了结果,表明提示工程对获得可靠输出至关重要。
  • 尽管结果令人鼓舞,但本研究也承认局限性,包括依赖 GPT-3.5(而非 GPT-4)、数据集覆盖不全,以及将源代码上传至外部服务器带来的安全顾虑。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。