paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Discrete Adversarial Attack to Models of Code

代码模型的离散对抗攻击
PLDI 7(PLDI)2023匹配度 4/10 · 论文研究代码模型的语义保持程序变换离散对抗攻击及对抗训练,属于机器学习与程序语言的交叉,但不涉及用户核心关注的静态分析、Agentic/LLM 程序、浮点程序分析或贝叶斯程序分析。其理论加实现的风格可能有一定参考价值,但整体研究方向匹配度有限。引用 23 inbox
Fengjuan Gao, Yu Wang, Ke Wang
crossref: 2026-09-10

AI 速览

一句话:提出针对代码模型的语义保持程序变换离散对抗攻击,并给出对抗训练的理论基础与实现以提升鲁棒性。

本文研究代码模型特有的离散对抗样本:通过保持程序语义的程序变换生成对抗输入,使模型预测错误。作者提出一种通用且高效的攻击方法,可作用于多种代码模型;并从防御角度建立理论基础,说明对抗训练可用于防御离散对抗攻击。基于该理论,作者实现了一个简单的对抗训练方案。实验广泛评估攻击与防御,结果表明离散攻击在有无防御机制时均显著优于现有方法,而该对抗训练实现使所有评估模型在面对现有攻击及本文攻击时鲁棒性提升幅度最大。

问题
如何针对代码模型生成保持语义的离散对抗样本,并有效防御此类攻击。
方法
提出通用离散对抗攻击方法,通过保持语义的程序变换生成对抗样本;从理论上论证对抗训练适用于防御代码模型,并实现简单的对抗训练方案。
评估
在多种代码模型上广泛评估攻击与防御,与现有方法比较攻击效果和鲁棒性提升。
原文摘要(Abstract)

The pervasive brittleness of deep neural networks has attracted significant attention in recent years. A particularly interesting finding is the existence of adversarial examples, imperceptibly perturbed natural inputs that induce erroneous predictions in state-of-the-art neural models. In this paper, we study a different type of adversarial examples specific to code models, called discrete adversarial examples , which are created through program transformations that preserve the semantics of original inputs.In particular, we propose a novel, general method that is highly effective in attacking a broad range of code models. From the defense perspective, our primary contribution is a theoretical foundation for the application of adversarial training — the most successful algorithm for training robust classifiers — to defending code models against discrete adversarial attack. Motivated by the theoretical results, we present a simple realization of adversarial training that substantially improves the robustness of code models against adversarial attacks in practice. We extensively evaluate both our attack and defense methods. Results show that our discrete attack is significantly more effective than state-of-the-art whether or not defense mechanisms are in place to aid models in resisting attacks. In addition, our realization of adversarial training improves the robustness of all evaluated models by the widest margin against state-of-the-art adversarial attacks as well as our own.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot1967,
  title = {Discrete Adversarial Attack to Models of Code},
  author = {Fengjuan Gao and Yu Wang and Ke Wang},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {7},
  number = {PLDI},
  year = {2023},
  doi = {10.1145/3591227}
}