Lune

ICSE2024Top-tier venue

GPTScan: Detecting Logic Vulnerabilities in Smart Contracts by Combining GPT with Program Analysis

Yuqiang Sun, Daoyuan Wu, Yue Xue, Han Liu, Haijun Wang, Zhengzi Xu, Xiaofei Xie, Yang Liu

Abstract

Smart contracts are prone to various vulnerabilities, leading to substantial financial losses over time. Current analysis tools mainly target vulnerabilities with fixed control-or data-flow patterns, such as re-entrancy and integer overflow. However, a recent study on Web3 security bugs revealed that about 80% of these bugs cannot be audited by existing tools due to the lack of domain-specific property description and checking. Given recent advances in Large Language Models (LLMs), it is worth exploring how Generative Pre-training Transformer (GPT) could aid in detecting logic vulnerabilities. In this paper, we propose GPTScan, the first tool combining GPT with static analysis for smart contract logic vulnerability detection. Instead of relying solely on GPT to identify vulnerabilities, which can lead to high false positives and is limited by GPT's pre-trained knowledge, we utilize GPT as a versatile code understanding tool. By breaking down each logic vulnerability type into scenarios and properties, GPTScan matches candidate vulnerabilities with GPT. To enhance accuracy, GPTScan further instructs GPT to intelligently recognize key variables and statements, which are then validated by static confirmation. Evaluation on diverse datasets with around 400 contract projects and 3K Solidity files shows that GPTScan achieves high precision (over 90%) for token contracts and acceptable precision (57.14%) for large projects like Web3Bugs. It effectively detects ground-truth logic vulnerabilities with a recall of over 70%, including 9 new vulnerabilities missed by human auditors. GPTScan is fast and cost-effective, taking an average of 14.39 seconds and 0.01 USD to scan per thousand lines of Solidity code. Moreover, static confirmation helps GPTScan reduce two-thirds of false positives.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

41 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Combining Fine-Tuning and LLM-Based Agents for Intuitive Smart Contract Auditing with Justifications cites ZEUS: Analyzing Safety of Smart Contracts
  • Combining Fine-Tuning and LLM-Based Agents for Intuitive Smart Contract Auditing with Justifications cites Large Language Models are Zero-Shot Reasoners
  • Combining Fine-Tuning and LLM-Based Agents for Intuitive Smart Contract Auditing with Justifications cites Language Models are Few-Shot Learners
  • Combining Fine-Tuning and LLM-Based Agents for Intuitive Smart Contract Auditing with Justifications cites Securify: Practical Security Analysis of Smart Contracts
  • Chasing Shadows: Pitfalls in LLM Security Research cites Semantic Sleuth: Identifying Ponzi Contracts via Large Language Models
  • Chasing Shadows: Pitfalls in LLM Security Research cites Language Models are Few-Shot Learners
  • Chasing Shadows: Pitfalls in LLM Security Research cites Training language models to follow instructions with human feedback
  • Large Language Models are Zero-Shot Reasoners cites Language Models are Few-Shot Learners
  • Large Language Models are Zero-Shot Reasoners cites Training language models to follow instructions with human feedback
  • Smart-LLaMA-DPO: Reinforced Large Language Model for Explainable Smart Contract Vulnerability Detection cites Combining Fine-Tuning and LLM-Based Agents for Intuitive Smart Contract Auditing with Justifications
  • Smart-LLaMA-DPO: Reinforced Large Language Model for Explainable Smart Contract Vulnerability Detection cites Securify: Practical Security Analysis of Smart Contracts
  • Training language models to follow instructions with human feedback cites Language Models are Few-Shot Learners
  • Enhancing Static Analysis for Practical Bug Detection: An LLM-Integrated Approach cites Training language models to follow instructions with human feedback
  • Securify: Practical Security Analysis of Smart Contracts cites ZEUS: Analyzing Safety of Smart Contracts
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers41

  1. Enhancing Static Analysis for Practical Bug Detection: An LLM-Integrated ApproachHaonan Li, Yu Hao, Yizhuo Zhai, Zhiyun QianOOPSLA 2024 · 142 citations
  2. Semantic Sleuth: Identifying Ponzi Contracts via Large Language ModelsCong Wu, Jing Chen, Ziwei Wang, Ruichao Liang et al.ASE 2024 · 29 citations
  3. Combining Fine-Tuning and LLM-Based Agents for Intuitive Smart Contract Auditing with JustificationsWei Ma, Daoyuan Wu, Yuqiang Sun, Tianwen Wang et al.ICSE 2025 · 28 citations
  4. Chasing Shadows: Pitfalls in LLM Security ResearchJonathan Evertz, Niklas Risse, Nicolai Neuer, Andreas Müller et al.NDSS 2026 · 17 citations
  5. Smart-LLaMA-DPO: Reinforced Large Language Model for Explainable Smart Contract Vulnerability DetectionLei Yu, Zhirong Huang, Hang Yuan, Shiqi Cheng et al.ISSTA 2025 · 13 citations

Builds on20

  1. Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
  2. Training language models to follow instructions with human feedbackLong Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida et al.NeurIPS 2022 · 24,707 citations
  3. Large Language Models are Zero-Shot ReasonersTakeshi Kojima, Shixiang Shane Gu, Machel Reid, Yutaka Matsuo et al.NeurIPS 2022 · 8,168 citations
  4. Securify: Practical Security Analysis of Smart ContractsPetar Tsankov, Andrei Marian Dan, Dana Drachsler-Cohen, Arthur Gervais et al.CCS 2018 · 1,108 citations
  5. ZEUS: Analyzing Safety of Smart ContractsSukrit Kalra, Seep Goel, Mohan Dhawan, Subodh SharmaNDSS 2018 · 595 citations

Related papers

  1. Have We Solved Access Control Vulnerability Detection in Smart Contracts? A Benchmark StudyHan Liu, Daoyuan Wu, Yuqiang Sun, Shuai Wang et al.ASE 2025 · 1 citation
  2. Detecting Bugs with Substantial Monetary Consequences by LLM and Rule-based ReasoningBrian Zhang, Zhuo ZhangNeurIPS 2024 · 12 citations
  3. VeriExploit: Automatic Bug Reproduction in Smart Contracts via LLMs and Formal MethodsChenfeng Wei, Shiyu Cai, Yiannis Charalambous, Tong Wu et al.ASE 2025
  4. Thought Is All You Need: Smart Contract Vulnerability Detection with Thought-Augmented Large Language ModelChaoyuan Peng, Muhui Jiang, Yajin Zhou, Lei WuFSE 2026
  5. PromFuzz: Leveraging LLM-Driven and Bug-Oriented Composite Analysis for Detecting Functional Bugs in Smart ContractsXingshuang Lin, Qinge Xie, Binbin Zhao, Yuan Tian et al.ASE 2025 · 5 citations
Dusk over the sea between two cliffs drawn in fine vertical lines