Skip to main content
QUICK REVIEW

[논문 리뷰] GPTScan: Detecting Logic Vulnerabilities in Smart Contracts by Combining GPT with Program Analysis

Yuqiang Sun, Daoyuan Wu|arXiv (Cornell University)|2023. 08. 07.
Software Engineering Research참고 문헌 36인용 수 14
한 줄 요약

GPTScan은 GPT 기반 코드 이해와 정적 분석을 결합해 Solidity 스마트 계약의 로직 취약점을 탐지하고, 여러 데이터셋에서 높은 정밀도와 재현율을 달성하며 정적 확인을 통해 거짓 양성 감소.

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 logicc 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.

연구 동기 및 목표

  • 대부분의 취약점이 로직 기반이고 패턴 기반 도구로 포착되지 않는 간극을 해소한다.
  • GPT를 코드 이해 도구로 활용해 취약점의 코드 수준 시나리오와 속성을 식별한다.
  • GPT 기반 매칭과 정적 확인을 결합해 후보 취약점을 검증한다.
  • 다양한 실제 데이터세트에서 GPTScan을 평가해 정밀도, 재현율 및 비용 효율성을 평가한다.

제안 방법

  • 로직 취약점 유형을 코드 수준의 시나리오와 속성으로 분해해 GPT 매칭에 활용한다.
  • 다차원 필터링을 적용해 GPT 분석 전 후보 함수들을 좁힌다.
  • 시나리오-그다음 속성 매칭 프롬트를 사용해 GPT-3.5-turbo로 가능성 높은 취약 함수 식별.
  • 정적 확인을 위해 핵심 변수와 진술을 추출하도록 GPT에 프롬프트한다.
  • 네 가지 정적 분석 모듈로 GPT로 식별된 후보를 검증한다: Data Flow Tracing, Value Comparison Check, Order Check, Function Call Argument Check.

실험 결과

연구 질문

  • RQ1일반적인 코드 이해 도구로서의 GPT가 정적 분석과 결합될 때 로직 취약점을 효과적으로 식별할 수 있는가?
  • RQ2다차원 필터링이 대형 Solidity 프로젝트에서 탐지 정확도를 유지하면서 GPT 비용을 어떻게 줄일 수 있는가?
  • RQ3정적 확인이 GPT 거짓 양성을 줄이고 정밀도를 향상시키는 데 어떤 영향을 미치는가?
  • RQ4토큰 계약과 대형 다중 파일 프로젝트에서 GPTScan의 정밀도와 재현율은 어떻게 다른가?

주요 결과

  • GPTScan은 토큰 계약(Token contracts)에서 높은 정밀도(90% 이상)를 달성했다(Top200 및 DefiHacks 데이터세트).
  • GPTScan은 Web3Bugs 같은 대형 프로젝트에서 허용 가능한 정밀도(57.14%)를 달성한다.
  • 실제 취약점으로 확인되는 로직 취약점은 재현율 70%를 넘으며, 인간 감사자가 보고하지 않은 9개의 새로운 취약점 포함.
  • 평균 스캔 시간은 14.39초이고 비용은 천 줄당 0.01 USD이며; 더 큰 프로젝트는 비용이 더 들고 스캔도 느리다(~0.018 USD 및 ~20초).
  • 정적 확인은 Web3Bugs 데이터세트에서 원래 거짓 양성의 65.84%를 감소시킨다.

더 나은 연구,지금 바로 시작하세요

연구 설계부터 논문 작성까지, 연구 시간을 획기적으로 줄여보세요.

카드 등록 없음 · 무료 플랜 제공

이 리뷰는 AI가 만들고, 인간 에디터가 검토했습니다.