[論文レビュー] Understanding the Effectiveness of Large Language Models in Detecting Security Vulnerabilities
本論文は、事前学習済みLLM(GPT-4、GPT-3.5、CodeLlama)をJavaおよびC/C++にわたる5つの脆弱性データセットでベンチマークし、脆弱性を検出し説明を提供するプロンプト戦略を開発し、静的解析および深層学習ツールと比較し、敵対的コードとファインチューニングの影響に対するロバスト性を分析する。
While automated vulnerability detection techniques have made promising progress in detecting security vulnerabilities, their scalability and applicability remain challenging. The remarkable performance of Large Language Models (LLMs), such as GPT-4 and CodeLlama, on code-related tasks has prompted recent works to explore if LLMs can be used to detect vulnerabilities. In this paper, we perform a more comprehensive study by concurrently examining a higher number of datasets, languages and LLMs, and qualitatively evaluating performance across prompts and vulnerability classes while addressing the shortcomings of existing tools. Concretely, we evaluate the effectiveness of 16 pre-trained LLMs on 5,000 code samples from five diverse security datasets. These balanced datasets encompass both synthetic and real-world projects in Java and C/C++ and cover 25 distinct vulnerability classes. Overall, LLMs across all scales and families show modest effectiveness in detecting vulnerabilities, obtaining an average accuracy of 62.8% and F1 score of 0.71 across datasets. They are significantly better at detecting vulnerabilities only requiring intra-procedural analysis, such as OS Command Injection and NULL Pointer Dereference. Moreover, they report higher accuracies on these vulnerabilities than popular static analysis tools, such as CodeQL. We find that advanced prompting strategies that involve step-by-step analysis significantly improve performance of LLMs on real-world datasets in terms of F1 score (by upto 0.18 on average). Interestingly, we observe that LLMs show promising abilities at performing parts of the analysis correctly, such as identifying vulnerability-related specifications and leveraging natural language information to understand code behavior (e.g., to check if code is sanitized). We expect our insights to guide future work on LLM-augmented vulnerability detection systems.
研究の動機と目的
- 事前学習済みLLMが複数のデータセットと言語でコードのセキュリティ脆弱性を検出できるかを評価する。
- LLMによる脆弱性検出の推論と説明を引き出すプロンプティング戦略を設計する。
- 静的解析(CodeQL)および深層学習(LineVul)アプローチとLLMの性能を比較する。
- データ漏洩と敵対的コード攻撃に対するロバスト性を評価し、性能へのファインチューニング効果を探る。
- LLMを脆弱性検出に活用するための知見と推奨を提供する。
提案手法
- 5つのデータセット(OWASP、Juliet Java、Juliet C/C++、CVEFixes Java、CVEFixes C/C++)でGPT-4、GPT-3.5、CodeLlama-7B、CodeLlama-13Bを評価する。
- 4つのプロンプト戦略を開発する:Basic、CWE-specific、Dataflow analysis-based、Dataflow with Self Reflection。
- LLMの結果をCodeQL(静的解析)およびLineVul(深層学習)と比較する。
- 意味論を保持した敵対的攻撃を通じたデータ漏洩を評価し、パフォーマンスへの影響を測定する。
- 小型モデルのファインチューニングと、それが合成データと実世界データセットのどちらに効果をもたらすかを検討する。
実験結果
リサーチクエスチョン
- RQ1多様なデータセットと言語で、事前学習済みLLMはコードのセキュリティ脆弱性を検出できるか。
- RQ2プロンプト戦略はLLMの脆弱性検出性能と説明可能性にどのように影響するか。
- RQ3標準的な脆弱性ベンチマークにおいて、LLMはCodeQLとLineVulとどう比較されるか。
- RQ4LLMsは敵対的なコード変更とデータ漏洩に対してロバストか。
- RQ5小型LLMのファインチューニングは性能を向上させ、データセット間で一般化は維持されるか。
主な発見
- Dataflow analysis-based prompt + Self Reflectionを用いたGPT-4は、syntheticデータセットでF1スコア0.79(OWASP)、0.86(Juliet Java)、0.89(Juliet C/C++)を達成する。
- 同じプロンプトで、GPT-4は実世界データセットのCVEFixes Javaで最大0.48、CVEFixes C/C++で最大0.62を達成する。
- CodeLlamaモデルは、syntheticデータセットで0.69–0.77、CVEFixes C/C++では最大0.65など、F1スコアが低めとなる。
- Self Reflectionは実世界データセットでGPT-4を「脆弱ではない」と予測する方向に寄与し、性能を低下させる傾向がある;CodeLlamaはこのケースでより堅牢性を示す。
- LineVulは大規模データで学習させたJuliet C/C++で1.0のF1を達成するが、CWEレベルの解釈可能な説明には欠ける;GPT-4はより解釈可能な推論を提供する。
- 敵対的なコード攻撃は軽度の劣化を引き起こし(特定の攻撃で平均最大12.67%)、ファインチューニングによって合成データの結果は改善するが、実世界データでは限られた利益しか得られない。
より良い研究を、今すぐ始めましょう
論文設計から論文執筆まで、研究時間を劇的に削減しましょう。
クレジットカード登録不要
このレビューはAIが作成し、人間の編集者が確認しました。