arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2602.16741cs.CRcs.AIcs.LG
收藏

对抗性代码注释能否欺骗AI安全审查员 -- 大规模实证研究:基于注释的攻击与防御对抗大语言模型代码分析

Can Adversarial Code Comments Fool AI Security Reviewers -- Large-Scale Empirical Study of Comment-Based Attacks and Defenses Against LLM Code Analysis

Scott Thornton

AI总结:

研究探讨了对抗性代码注释对AI安全审查的影响,发现其对漏洞检测无显著影响,静态分析交叉参考效果最佳。

摘要:

AI辅助的代码审查被广泛用于在发布前检测漏洞。先前的研究表明,对抗性提示操纵会降低大语言模型(LLM)在代码生成中的性能。我们测试了类似的基于注释的操纵是否会导致LLM在漏洞检测中产生误解。我们构建了一个包含Python、JavaScript和Java的100个样本基准,每种语言配对八个注释变体,从无注释到对抗性策略如权威伪装和技术欺骗。八个前沿模型,五种商业和三种开源模型,在9366次试验中进行评估。对抗性注释对检测准确率产生小而统计上不显著的影响(McNemar精确p>0.21;所有95%置信区间包含零)。这适用于商业模型(基线检测率为89至96%)和开源模型(基线检测率为53至72%),尽管存在较大的绝对性能差距。与生成设置中注释操纵实现高攻击成功率不同,检测性能没有明显下降。更复杂的对抗性策略在简单操纵注释上没有任何优势。我们测试了四种自动化防御方法,在4646次额外试验(总计14012次)中进行。静态分析交叉参考在检测方面表现最佳,达到96.9%的检测率,并恢复了47%的基线遗漏。注释移除会减少较弱模型的检测,通过移除有用的上下文。失败集中在本质上困难的漏洞类别上,包括竞态条件、定时侧信道和复杂的授权逻辑,而不是对抗性注释上。

英文摘要:

AI-assisted code review is widely used to detect vulnerabilities before production release. Prior work shows that adversarial prompt manipulation can degrade large language model (LLM) performance in code generation. We test whether similar comment-based manipulation misleads LLMs during vulnerability detection. We build a 100-sample benchmark across Python, JavaScript, and Java, each paired with eight comment variants ranging from no comments to adversarial strategies such as authority spoofing and technical deception. Eight frontier models, five commercial and three open-source, are evaluated in 9,366 trials. Adversarial comments produce small, statistically non-significant effects on detection accuracy (McNemar exact p > 0.21; all 95 percent confidence intervals include zero). This holds for commercial models with 89 to 96 percent baseline detection and open-source models with 53 to 72 percent, despite large absolute performance gaps. Unlike generation settings where comment manipulation achieves high attack success, detection performance does not meaningfully degrade. More complex adversarial strategies offer no advantage over simple manipulative comments. We test four automated defenses across 4,646 additional trials (14,012 total). Static analysis cross-referencing performs best at 96.9 percent detection and recovers 47 percent of baseline misses. Comment stripping reduces detection for weaker models by removing helpful context. Failures concentrate on inherently difficult vulnerability classes, including race conditions, timing side channels, and complex authorization logic, rather than on adversarial comments.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑