Do Language Models Learn Semantics of Code? A Case Study in Vulnerability Detection

要約

最近、事前トレーニングされた言語モデルが脆弱性検出タスクで最先端のパフォーマンスを示しました。
これらのモデルは、ソース コードの大規模なコーパスで事前トレーニングされ、その後、小規模な教師付き脆弱性データセットで微調整されます。
トレーニングの目的とモデルのパフォーマンスが異なるため、モデルが脆弱性検出に関連するコードのセマンティクス、つまりバグ セマンティクスを学習したかどうか、学習している場合はバグ セマンティクスとの調整がモデルのパフォーマンスにどのように関連するかを検討することは興味深いことです。

このペーパーでは、解釈可能性ツール、注意分析、および相互作用行列分析という 3 つの異なる方法を使用してモデルを分析します。
モデルの影響力のある特徴セットを、バグのあるパスや潜在的に脆弱なステートメント (PVS) など、バグの原因を定義するバグ セマンティック特徴と比較します。
その結果、(1) パフォーマンスの高いモデルは PVS との整合性も高く、(2) モデルは PVS との整合性が低く、(3) モデルはバグのあるパスとまったく整合しなかったことがわかりました。
私たちの分析に基づいて、モデルの入力内のバグのセマンティクスを強調する 2 つのアノテーション方法を開発しました。
4 つの異なるトランスフォーマー モデルと 4 つの脆弱性データセットでアプローチを評価したところ、アノテーションによって大部分の設定 (16 個中 11 個) でモデルのパフォーマンスが向上し、従来の微調整と比較して F1 スコアが最大 9.57 ポイント向上したことがわかりました。
さらに、アノテーションを使用すると、潜在的に脆弱なステートメントに対してモデルが最大 232% 良く適合することがわかりました。
私たちの調査結果は、モデルにバグ セマンティクスの情報を提供することが有益であること、モデルがそれに対応できること、そしてより複雑なパスベースのバグ セマンティクスを学習する将来の作業の動機付けとなることを示しています。
コードとデータは https://figshare.com/s/4a16a528d6874aad51a0 で入手できます。

要約(オリジナル)

Recently, pretrained language models have shown state-of-the-art performance on the vulnerability detection task. These models are pretrained on a large corpus of source code, then fine-tuned on a smaller supervised vulnerability dataset. Due to the different training objectives and the performance of the models, it is interesting to consider whether the models have learned the semantics of code relevant to vulnerability detection, namely bug semantics, and if so, how the alignment to bug semantics relates to model performance. In this paper, we analyze the models using three distinct methods: interpretability tools, attention analysis, and interaction matrix analysis. We compare the models’ influential feature sets with the bug semantic features which define the causes of bugs, including buggy paths and Potentially Vulnerable Statements (PVS). We find that (1) better-performing models also aligned better with PVS, (2) the models failed to align strongly to PVS, and (3) the models failed to align at all to buggy paths. Based on our analysis, we developed two annotation methods which highlight the bug semantics inside the model’s inputs. We evaluated our approach on four distinct transformer models and four vulnerability datasets and found that our annotations improved the models’ performance in the majority of settings – 11 out of 16, with up to 9.57 points improvement in F1 score compared to conventional fine-tuning. We further found that with our annotations, the models aligned up to 232% better to potentially vulnerable statements. Our findings indicate that it is helpful to provide the model with information of the bug semantics, that the model can attend to it, and motivate future work in learning more complex path-based bug semantics. Our code and data are available at https://figshare.com/s/4a16a528d6874aad51a0.

arxiv情報

著者 Benjamin Steenhoek,Md Mahbubur Rahman,Shaila Sharmin,Wei Le
発行日 2023-11-07 16:31:56+00:00
arxivサイト arxiv_id(pdf)

提供元, 利用サービス

arxiv.jp, Google

カテゴリー: cs.CR, cs.LG パーマリンク