Skip to main content
QUICK REVIEW

[논문 리뷰] Combining Fine-Tuning and LLM-based Agents for Intuitive Smart Contract Auditing with Justifications

Wei Ma, Daoyuan Wu|arXiv (Cornell University)|2024. 03. 24.
Blockchain Technology Applications and SecurityComputer Science인용 수 5
한 줄 요약

TrustLLM은 두 단계 미세 조정 방식(Detector와 Reasoner)을 Ranker 및 Critic LLM 기반 에이전트와 결합하여 Solidity 스마트 계약을 JUSTIFICATIONS와 함께 감사합니다? 정확히: Justifications로 감사하며 실제 데이터에서 취약점 탐지 성능과 설명 일관성을 달성합니다.

ABSTRACT

Smart contracts are decentralized applications built atop blockchains like Ethereum. Recent research has shown that large language models (LLMs) have potential in auditing smart contracts, but the state-of-the-art indicates that even GPT-4 can achieve only 30% precision (when both decision and justification are correct). This is likely because off-the-shelf LLMs were primarily pre-trained on a general text/code corpus and not fine-tuned on the specific domain of Solidity smart contract auditing. In this paper, we propose iAudit, a general framework that combines fine-tuning and LLM-based agents for intuitive smart contract auditing with justifications. Specifically, iAudit is inspired by the observation that expert human auditors first perceive what could be wrong and then perform a detailed analysis of the code to identify the cause. As such, iAudit employs a two-stage fine-tuning approach: it first tunes a Detector model to make decisions and then tunes a Reasoner model to generate causes of vulnerabilities. However, fine-tuning alone faces challenges in accurately identifying the optimal cause of a vulnerability. Therefore, we introduce two LLM-based agents, the Ranker and Critic, to iteratively select and debate the most suitable cause of vulnerability based on the output of the fine-tuned Reasoner model. To evaluate iAudit, we collected a balanced dataset with 1,734 positive and 1,810 negative samples to fine-tune iAudit. We then compared it with traditional fine-tuned models (CodeBERT, GraphCodeBERT, CodeT5, and UnixCoder) as well as prompt learning-based LLMs (GPT4, GPT-3.5, and CodeLlama-13b/34b). On a dataset of 263 real smart contract vulnerabilities, iAudit achieves an F1 score of 91.21% and an accuracy of 91.11%. The causes generated by iAudit achieved a consistency of about 38% compared to the ground truth causes.

연구 동기 및 목표

  • 인간의 직관을 모방하여 스마트 계약 감사를 개선하려는 동기 부여: 먼저 잠재적 취약점을 파악하고, 그런 다음 원인을 분석한다.
  • 취약점 탐지(Detector)와 원인 추론(Reasoner)을 분리하는 두 단계 미세 조정 프레임워크를 개발한다.
  • LLM 기반 Ranker와 Critic 에이전트를 통해 설명의 품질을 향상시키고 토론하며 최상의 취약점 원인을 선택한다.
  • 고품질 감사 보고서 및 데이터 강화 기법을 활용하여 미세 조정을 위한 균형 데이터 세트를 구성한다.
  • 탐지 및 정당화 과제에서 전통적인 미세 조정된 모델과 제로샷 LLM에 대해 TrustLLM을 평가한다.

제안 방법

  • 두 단계 미세 조정: 취약점 여부를 판단하는 Detector와 원인을 생성하는 Reasoner를 별도로 학습시킨다.
  • 입력마다 여러 프롬트를 사용하여 다양한 추론 경로를 생성하고 다수결 투표를 적용해 견고한 결정을 내린다(Detector).
  • 제로샷 사고 흐름 프롬프트로 Reasoner를 미세 조정하여 주어진 라벨에 대한 여러 설명을 생성한다.
  • 가장 적절한 취약점 원인을 반복적으로 선택하고 토론하는 Ranker 및 Critic LLM 기반 에이전트를 도입한다(랭킹 및 검증).
  • 감사 보고서(양수 샘플)와 데이터 강화 파이프라인(음수 샘플)을 통해 균형 데이터 세트(1,734 양수, 1,810 음수)를 구성한다.
  • 취약점 탐지에서 TrustLLM을 전통적 미세 조정 모델(CodeBERT, GraphCodeBERT, CodeT5, UnixCoder) 및 제로샷 LLM(GPT-4, GPT-3.5, CodeLlama)과 비교한다.

실험 결과

연구 질문

  • RQ1RQ1: TrustLLM의 취약점 탐지 성능은 기존의 미세 조정 모델 및 제로샷 LLM과 비교하여 어떤가요?
  • RQ2RQ2: Reasoner가 생성한 설명은 실제 취약점 원인과 얼마나 잘 일치합니까?
  • RQ3RQ3: 두 단계 접근법은 라벨과 원인을 함께 출력하는 통합 모델보다 우수한가요?
  • RQ4RQ4: 다수결 투표가 탐지기 성능과 안정성을 향상시키나요?
  • RQ5RQ5: 추가 정보(예: 호출 그래프)가 탐지 및 설명 품질에 미치는 영향은 어떠한가요?

주요 결과

  • TrustLLM은 취약점 탐지에서 제로샷 LLM 및 전통적 미세 조정 모델보다 우수한 성능을 보이며 F1 0.9121 및 정확도 0.9111를 달성합니다.
  • 제로샷 베이스라인 중 GPT-4 및 GPT-3.5는 재현율이 1.0에 도달했으나 정밀도와 전반적 정확도는 TrustLLM에 비해 현저히 낮았습니다.
  • Reasoner의 설명은 실제 원인과의 정합성(일관성 37.99%)이 더 높아 GPT-4(24.13%)를 능가했습니다.
  • 다수결 투표와 다중 프롬프트 전략은 단일 프롬프트 접근법보다 취약점 결정의 안정성과 성능을 향상시킵니다.
  • 호출 그래프 정보는 경우에 따라 도움이 되기도 하지만 모델을 혼란스럽게 할 수 있으며 성능에 혼합된 영향을 미칩니다.

이 논문 읽기

누빈트 뷰어에서 원문을 열고, 읽으면서 궁금한 곳을 바로 물어보세요.

누빈트에서 이 논문 읽기

이 리뷰는 AI가 논문 원문을 바탕으로 만들었습니다. 인용하기 전에 원문을 확인해 주세요.