日本語タイトル#
大規模言語モデルを用いた明示的脆弱性生成:対抗攻撃を超えた研究
英文タイトル#
Explicit Vulnerability Generation with LLMs: An Investigation Beyond Adversarial Attacks
日本語摘要#
大規模言語モデル(LLMs)はコードアシスタントとしてますます使用されていますが、安全でないコードを生成するよう明示的に求められたときの挙動はほとんど理解されていません。以前の研究は意図しない脆弱性に焦点を当てていましたが、本研究はより直接的な脅威を調査します:オープンソースの LLMs がプロンプトに応じて脆弱なコードを生成することです。私たちは二重実験デザインを提案します:(1)動的プロンプティング:構造化されたテンプレート内で脆弱性の種類、ユーザーペルソナ、プロンプトの表現を体系的に変化させる;および(2)逆プロンプティング:実際の脆弱なコードサンプルから自然言語プロンプトを導出する。私たちは、生成された脆弱性の存在と正確性を評価するために、静的分析を使用して 3 つのオープンソース 7B パラメータモデル(Qwen2、Mistral、Gemma)を評価します。私たちの結果は、すべてのモデルが要求された脆弱性を頻繁に生成することを示していますが、パフォーマンスには顕著な差があります。動的プロンプティングの下で、Gemma はメモリ脆弱性に対して最も高い正確性を達成します(例:バッファオーバーフローの正確率は 98.6%)、一方で Qwen2 はすべてのタスクで最もバランスの取れたパフォーマンスを示します。私たちは、専門的なペルソナ(例:「DevOps エンジニア」)が常に学生のペルソナよりも高い成功率を引き出すことを発見し、直接的な表現と間接的な表現の有効性はプロンプティング戦略によって逆転することを示します。脆弱性再現の正確性はコードの複雑性と非線形のパターンに従い、中程度の範囲でピークに達します。私たちの発見は、LLMs が意味的推論よりもパターンの記憶に依存することが、特に合理的な専門的タスクとして提示された要求において、安全性の整合性に重大な盲点を生じさせることを明らかにします。
英文摘要#
Large Language Models (LLMs) are increasingly used as code assistants, yet their behavior when explicitly asked to generate insecure code remains poorly understood. While prior research has focused on unintended vulnerabilities, this study examines a more direct threat: open-source LLMs generating vulnerable code when prompted. We propose a dual experimental design: (1) Dynamic Prompting, which systematically varies vulnerability type, user persona, and prompt phrasing across structured templates; and (2) Reverse Prompting, which derives natural-language prompts from real vulnerable code samples. We evaluate three open-source 7B-parameter models (Qwen2, Mistral, Gemma) using static analysis to assess both the presence and correctness of generated vulnerabilities. Our results show that all models frequently generate the requested vulnerabilities, though with significant performance differences. Gemma achieves the highest correctness for memory vulnerabilities under Dynamic Prompting (e.g., 98.6% for buffer overflows), while Qwen2 demonstrates the most balanced performance across all tasks. We find that professional personas (e.g., "DevOps Engineer") consistently elicit higher success rates than student personas, and that the effectiveness of direct versus indirect phrasing is inverted depending on the prompting strategy. Vulnerability reproduction accuracy follows a non-linear pattern with code complexity, peaking in a moderate range. Our findings expose how LLMs' reliance on pattern recall over semantic reasoning creates significant blind spots in their safety alignments, particularly for requests framed as plausible professional tasks.
PDF 获取#
抖音扫码查看更多精彩内容