Skip to main content
QUICK REVIEW

[Paper Review] When ChatGPT Meets Smart Contract Vulnerability Detection: How Far Are We?

Chong Chen, Jianzhong Su|arXiv (Cornell University)|Sep 11, 2023
Blockchain Technology Applications and SecurityComputer Science5 citations
TL;DR

This paper evaluates ChatGPT's effectiveness in detecting smart contract vulnerabilities using the SmartBugs dataset, revealing high recall but low precision, especially for certain vulnerability types. It identifies four root causes of false positives and compares ChatGPT against 11 SOTA tools, finding it outperforms others in only four of seven vulnerability categories, highlighting limitations in robustness and code length handling.

ABSTRACT

With the development of blockchain technology, smart contracts have become an important component of blockchain applications. Despite their crucial role, the development of smart contracts may introduce vulnerabilities and potentially lead to severe consequences, such as financial losses. Meanwhile, large language models, represented by ChatGPT, have gained great attentions, showcasing great capabilities in code analysis tasks. In this paper, we presented an empirical study to investigate the performance of ChatGPT in identifying smart contract vulnerabilities. Initially, we evaluated ChatGPT's effectiveness using a publicly available smart contract dataset. Our findings discover that while ChatGPT achieves a high recall rate, its precision in pinpointing smart contract vulnerabilities is limited. Furthermore, ChatGPT's performance varies when detecting different vulnerability types. We delved into the root causes for the false positives generated by ChatGPT, and categorized them into four groups. Second, by comparing ChatGPT with other state-of-the-art smart contract vulnerability detection tools, we found that ChatGPT's F-score is lower than others for 3 out of the 7 vulnerabilities. In the case of the remaining 4 vulnerabilities, ChatGPT exhibits a slight advantage over these tools. Finally, we analyzed the limitation of ChatGPT in smart contract vulnerability detection, revealing that the robustness of ChatGPT in this field needs to be improved from two aspects: its uncertainty in answering questions; and the limited length of the detected code. In general, our research provides insights into the strengths and weaknesses of employing large language models, specifically ChatGPT, for the detection of smart contract vulnerabilities.

Motivation & Objective

  • To assess the effectiveness of ChatGPT in detecting smart contract vulnerabilities across multiple vulnerability types.
  • To identify and categorize the root causes of false positives generated by ChatGPT during vulnerability detection.
  • To compare ChatGPT’s performance against 11 state-of-the-art smart contract vulnerability detection tools.
  • To analyze the limitations of ChatGPT in this domain, particularly regarding response uncertainty and code length constraints.
  • To provide insights into the practical feasibility and improvement needs of using LLMs like ChatGPT for blockchain security.

Proposed method

  • The study uses the widely adopted SmartBugs-curated dataset containing 142 vulnerable smart contracts across nine vulnerability categories defined by DASP10.
  • A standardized prompt was designed to instruct ChatGPT (GPT-3.5 and GPT-4) to detect each of the nine vulnerability types.
  • Performance was evaluated using standard metrics: precision, recall, and F1-score to quantify detection effectiveness.
  • False positives were systematically analyzed and categorized into four distinct types: Protected Mechanism Bias, Development Intent Bias, Interference from Comments, and Interference from Dead Code.
  • A comparative evaluation was conducted against 11 SOTA tools (e.g., Mythril, Confuzzius) on the same dataset to benchmark performance.
  • The analysis also examined ChatGPT’s limitations, particularly its instability in responses and constraints on input code length.

Experimental results

Research questions

  • RQ1RQ1: How effective is ChatGPT in detecting vulnerabilities in smart contracts, and how does its performance vary across different vulnerability types?
  • RQ2RQ2: How does ChatGPT’s detection performance compare to other state-of-the-art smart contract vulnerability detection tools?
  • RQ3RQ3: What are the root causes of false positives generated by ChatGPT in smart contract vulnerability detection?
  • RQ4RQ4: What are the key limitations of ChatGPT in this context, particularly regarding robustness and input length?

Key findings

  • ChatGPT achieved a recall rate of 51.4% for GPT-3.5 and 88.2% for GPT-4, indicating strong ability to identify many actual vulnerabilities.
  • However, precision was low, at only 19.7% for GPT-3.5 and 22.6% for GPT-4, indicating a high rate of false positives.
  • For specific vulnerabilities like Short Address Attack, both GPT-3.5 and GPT-4 showed poor performance, while they performed well on Unchecked Return Values.
  • ChatGPT outperformed 11 other tools in detecting Front Running and Denial of Service vulnerabilities, but its F1-scores were low at 12.8% and 15.9% respectively.
  • False positives were primarily caused by four categories: Protected Mechanism Bias, Development Intent Bias, interference from comments, and interference from dead code.
  • ChatGPT demonstrated higher detection failure rates than 81.8% of the evaluated tools and faces limitations in robustness and handling long code inputs.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.