[論文レビュー] Combining Fine-Tuning and LLM-based Agents for Intuitive Smart Contract Auditing with Justifications
TrustLLM は、Detector と Reasoner の二段階微調整アプローチを、Ranker および Critic LLM ベースのエージェントと組み合わせて、Solidity のスマートコントラクトを正当化付きで監査し、実世界データで高い脆弱性検出性能と説明の一貫性を達成します。
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 をゼロショットの chain-of-thought プロンプトで微調整し、与えられたラベルに対して複数の説明を生成します。
- Ranker および Critic LLM ベースのエージェントを導入して、最も適切な脆弱性原因を反復的に選択・討論します(ランキングと検証)。
- 監査レポート(正例)とデータ拡張パイプライン(負例)から学習データを組み立て、バランスのとれたデータセットを作成します(1,734 正例、1,810 負例)。
- 脆弱性検出において、従来のファインチューニング済みモデル(CodeBERT, GraphCodeBERT, CodeT5, UnixCoder)およびゼロショット LLM(GPT-4, GPT-3.5, CodeLlama)と TrustLLM を比較します。
実験結果
リサーチクエスチョン
- RQ1RQ1: TrustLLM の脆弱性検出性能は、既存のファインチューニング済みモデルおよびゼロショット LLM と比べてどうか?
- RQ2RQ2: Reasoner が生成した説明は、実際の脆弱性原因とどの程度一致するか?
- RQ3RQ3: 二段階アプローチは、ラベルと原因を共同で出力する統合モデルより優れているか?
- RQ4RQ4: 過半数投票は検出器の性能と安定性を改善するか?
- RQ5RQ5: 追加情報(例:呼び出しグラフ)が検出および説明品質に与える影響は何か?
主な発見
- TrustLLM は、ゼロショット LLM および従来のファインチューニング済みモデルを脆弱性検出で上回り、F1 0.9121 および accuracy 0.9111 を達成。
- ゼロショットベースラインの中で、GPT-4 および GPT-3.5 は recall を 1.0 に達したが、精度と全体の精度は TrustLLM に比べてはるかに劣る。
- Reasoner の説明は、実データの原因との整合性が高く(整合性 37.99%)、GPT-4(24.13%)を上回った。
- 過半数投票とマルチプロンプト戦略は、単一プロンプト手法より脆弱性判断の安定性と性能を向上させる。
- 呼び出しグラフ情報は一部のケースで役立つが、モデルを混乱させる場合もあり、性能には混在した影響を与える。
この論文を読む
Nubintのビューアで原文を開き、読みながら気になる箇所をすぐに質問できます。
Nubintでこの論文を読むこのレビューはAIが論文の原文をもとに作成しました。引用する前に原文をご確認ください。