[論文レビュー] Adversarial Attacks on Code Models with Discriminative Graph Patterns
本稿では、モデルの挙動から特徴的な抽象構文木(AST)パターンを自動で抽出し、意味を保ちつつ高い影響を持つ摂動を生成する、ブラックボックスな敵対的攻撃フレームワークであるGraphCodeAttackを提案する。ASTの部分グラフの中でモデルの予測に最も影響を与えるものを同定し、事前に訓練されたコードモデルを用いてそれらを現実的ないわゆるデッドコード挿入に変換することで、CodeBERTおよびGraphCodeBERTの3つのタスクにおいて、CARROT よりも30%、ALERT よりも33%高い攻撃成功確率(ASR)を達成した。
Pre-trained language models of code are now widely used in various software engineering tasks such as code generation, code completion, vulnerability detection, etc. This, in turn, poses security and reliability risks to these models. One of the important threats is extit{adversarial attacks}, which can lead to erroneous predictions and largely affect model performance on downstream tasks. Current adversarial attacks on code models usually adopt fixed sets of program transformations, such as variable renaming and dead code insertion, leading to limited attack effectiveness. To address the aforementioned challenges, we propose a novel adversarial attack framework, GraphCodeAttack, to better evaluate the robustness of code models. Given a target code model, GraphCodeAttack automatically mines important code patterns, which can influence the model's decisions, to perturb the structure of input code to the model. To do so, GraphCodeAttack uses a set of input source codes to probe the model's outputs and identifies the extit{discriminative} ASTs patterns that can influence the model decisions. GraphCodeAttack then selects appropriate AST patterns, concretizes the selected patterns as attacks, and inserts them as dead code into the model's input program. To effectively synthesize attacks from AST patterns, GraphCodeAttack uses a separate pre-trained code model to fill in the ASTs with concrete code snippets. We evaluate the robustness of two popular code models (e.g., CodeBERT and GraphCodeBERT) against our proposed approach on three tasks: Authorship Attribution, Vulnerability Prediction, and Clone Detection. The experimental results suggest that our proposed approach significantly outperforms state-of-the-art approaches in attacking code models such as CARROT and ALERT.
研究の動機と目的
- 変数名の置き換えやデッドコード挿入といった固定された手作業による変換に依存する、既存のコードモデル向け敵対的攻撃の限界を是正すること。
- 白ボックスアクセスを必要とせず、モデルに依存しない方法で、コードモデルの予測に顕著に影響を与える敵対的パターンを自動で同定する手法を開発すること。
- 現在の最先端の手法よりもより効果的で複雑な敵対的例を生成することで、事前学習済みコードモデルのロバストネス評価を向上させること。
- 攻撃の成功確率を維持したまま、攻撃に必要なトークン変更数を減らし、攻撃の効率性と不審性を高めること。
提案手法
- GraphCodeAttackはブラックボックス設定で動作し、モデル出力と入力プログラムのみを用いて意思決定境界を調査する。
- 入力プログラムとその対応するモデル予測から、モデル意思決定に最も影響を与える特徴的なAST部分グラフを抽出する。
- 高い影響を持つASTパターンを選別し、別途事前に訓練されたコードモデルを用いて、それらのパターンに適合する具体的な構文的に正しいコードスニペットを生成する。
- これらの具体的なスニペットを元のプログラムにデッドコードとして挿入することで、意味を保ちつつモデル予測を変更する敵対的例を生成する。
- 攻撃合成フェーズでは、事前に訓練されたコードモデルを活用し、摂動を加えたコードの構文的正しさと自然さを保証する。
- 本手法は、CodeBERTおよびGraphCodeBERTという2つの代表的なコードモデルを用い、著者識別、脆弱性予測、クローン検出の3つのタスクで評価された。

実験結果
リサーチクエスチョン
- RQ1自動で抽出されたASTパターンは、手作業による変換よりも、コードモデル向けの敵対的例作成においてより効果的であるか?
- RQ2CARROT や ALERT といった最先端のブラックボックス攻撃と比較して、GraphCodeAttackは多様なコードモデルタスクにおいて攻撃成功確率(ASR)でどの程度優れているか?
- RQ3GraphCodeAttackは、攻撃に必要なトークン変更数をどの程度削減できるか。これは攻撃の効率性と不審性の指標となる。
- RQ4GraphCodeAttackを用いた敵対的ファインチューニングにより、完全な敵対的学習やターゲットモデルの出力アクセスを必要とせずに、モデルのロバストネスを向上させることができるか?
主な発見
- GraphCodeAttackは、著者識別タスクにおいてGraphCodeBERTモデルで平均ASR 0.841を達成し、CARROT(ASR: 0.598)とALERT(ASR: 0.615)を著しく上回った。
- 全評価タスクおよびモデル全体で、GraphCodeAttackはCARROTに比べて平均30%、ALERTに比べて33%高いASRを達成した。
- ベースライン手法よりも少ないトークン変更で攻撃が成功しており、入力ファイルサイズが大きくなるにつれてコード変更率が低下した。これは、より高い効率性と低い検知可能性を示している。
- GraphCodeAttackを用いた敵対的ファインチューニングは、ALERTと同等のロバストネス向上を達成したが、ターゲットモデルの出力アクセスやデータセット全体の敵対的学習を必要としていなかった。
- 本手法は、脆弱性予測やクローン検出を含む多様なタスクにわたり、優れた汎化性能を示し、単一の応用にとどまらない有効性を確認した。
- 事前に訓練されたコードモデルを用いてASTパターンを具体化することで、生成された敵対的例の構文的正しさと自然さが保証された。

より良い研究を、今すぐ始めましょう
論文の読解から最終レビューまで、研究時間を劇的に削減しましょう。
クレジットカード登録不要
このレビューはAIが作成し、人間の編集者が確認しました。