代码语言模型(Code Language Models, CLMs),尤其是基于深度学习的代码语言模型,已在代码智能领域取得显著成功。但这一过程中安全问题常被忽视,尤其是后门攻击。现有研究多聚焦于为CLMs设计后门攻击,而有效防御手段尚未得到充分研究。特别是自然语言处理领域的现有防御方法直接应用于CLMs时效果不佳且缺乏通用性,仅在部分模型和场景下有效,在其他场景中失效,因此无法持续缓解后门攻击。为填补这一空白,我们首先证实“早学”现象是CLMs训练过程中的普遍现象:模型初始阶段会关注训练数据的主要特征,但随训练推进可能对后门触发器愈发敏感,进而导致过拟合并易受后门攻击。我们进一步分析发现,对后门触发器的过拟合源于交叉熵损失函数的使用——交叉熵的无界性会使模型越来越关注中毒数据的特征。基于这一洞察,我们提出一种通用且有效的损失函数DeCE(欺骗性交叉熵),通过融合欺骗性分布并应用标签平滑将梯度限制在有界范围内,防止模型对后门触发器过拟合,从而提升CLMs抵御后门攻击的安全性。
英文摘要:
Code Language Models (CLMs), particularly those leveraging deep learning, have achieved significant success in code intelligence domain. However, the issue of security, particularly backdoor attacks, is often overlooked in this process. The previous research has focused on designing backdoor attacks for CLMs, but effective defenses have not been adequately addressed. In particular, existing defense methods from natural language processing, when directly applied to CLMs, are not effective enough and lack generality, working well in some models and scenarios but failing in others, thus fall short in consistently mitigating backdoor attacks. To bridge this gap, we first confirm the phenomenon of "early learning" as a general occurrence during the training of CLMs. This phenomenon refers to that a model initially focuses on the main features of training data but may become more sensitive to backdoor triggers over time, leading to overfitting and susceptibility to backdoor attacks. We then analyze that overfitting to backdoor triggers results from the use of the cross-entropy loss function, where the unboundedness of cross-entropy leads the model to increasingly concentrate on the features of the poisoned data. Based on this insight, we propose a general and effective loss function DeCE (Deceptive Cross-Entropy) by blending deceptive distributions and applying label smoothing to limit the gradient to bounded, which prevents the model from overfitting to backdoor triggers and then enhances the security of CLMs against backdoor attacks.
Defending Against Weight-Poisoning Backdoor Attacks for Parameter-Efficient Fine-Tuning
Nanyang Technological University(南洋理工大学);Hong Kong University of Science and Technology(香港科技大学);Jinan University(暨南大学);Sony Research(索尼研究院);Zhejiang University(浙江大学);Beijing Institute of Technology(北京理工大学)
Buffer is All You Need: Defending Federated Learning against Backdoor Attacks under Non-iids via Buffering
Miner School of Computer and Information Sciences, University of Massachusetts Lowell(马萨诸塞大学洛厄尔分校迈纳计算机与信息科学学院);University of South Florida(南佛罗里达大学);University of Kentucky(肯塔基大学);Purdue University(普渡大学);North Carolina State University(北卡罗来纳州立大学)
Defending Against Backdoor Attacks via Alignment Checking in Model-Contrastive Federated Learning
Shandong Computer Science Center(山东计算机科学中心);Qilu University of Technology (Shandong Academy of Sciences)(齐鲁工业大学(山东省科学院));College of computer science and technology, China University of Petroleum(中国石油大学计算机科学与技术学院);School of Computer Science and Engineering, University of Electronic Science and Technology of China(电子科技大学计算机科学与工程学院);Big Data Institute, Qilu University of Technology(齐鲁工业大学大数据研究院)
Trap and Replace: Defending Backdoor Attacks by Trapping Them into an Easy-to-Replace Subnetwork
University of Texas at Austin(德克萨斯大学奥斯汀分校);Michigan State University(密歇根州立大学);Amazon Web Services(亚马逊云科技)
深度神经网络(DNN)容易受到后门攻击。以前的工作已经表明,从网络中消除不需要的后门行为是非常具有挑战性的,因为整个网络都可能受到后门样本的影响。在本文中,我们提出了一个全新的后门防御策略,这使得它更容易从模型中删除后门样本的有害影响。我们的防御战略,\emph{Trap and Replace},包括两个阶段。在第一阶段,我们在一个小而容易替换的子网中诱饵和陷阱后门。具体来说,我们在与轻量分类头共享的干网络之上添加辅助图像重建头。直觉是,辅助图像重建任务鼓励干网络保持足够的难以学习但语义正确的低级视觉特征,而不是过度拟合易于学习但语义不正确的后门相关性。因此,当在后门数据集上训练时,后门很容易被引诱到未受保护的分类头,因为它比共享的主干更容易受到攻击,使得主干网络几乎不会中毒。在第二阶段,我们用一个未污染的分类头替换中毒的轻量级分类头,只在一个具有干净样本的小数据集上从头开始重新训练它,同时修复干网络。因此,最终网络中的主干和分类头几乎不受后门训练样本的影响。我们评估我们的方法对十种不同的后门攻击。我们的方法在CIFAR 10、GTSRB和ImageNet-12上的攻击成功率和平均$3.14\%$、$1.80\%$和$1.21\%$干净分类准确率分别高达$20.57\%$、$9.80\%$和$13.72\%$,优于之前最先进的方法。代码可在线获取。
German Research Center for Artificial Intelligence(德国人工智能研究中心);Technical University of Darmstadt(达姆施塔特工业大学);TU Dortmund University(多特蒙德工业大学);Center for Trustworthy Data Science and Security, University Alliance Ruhr(鲁尔大学联盟可信数据科学与安全中心);Hessian Center for AI (hessian.AI)(黑森州人工智能中心);Centre for Cognitive Science TU Darmstadt(达姆施塔特工业大学认知科学中心)
Defending the Edge: Representative-Attention Defense against Backdoor Attacks in Federated Learning
Dept. of Computer Science Faculty of Engineering University of Manchester Manchester, United Kingdom;Dept. of Computer Science Faculty of Engineering University of Manchester \& MBZUAI Abu Dhabi, United Arab Emirates;Dept. of Computer Science Faculty of Engineering University of Manchester \& KU Leuven Manchester, United Kingdom
Sleeper Agents: Training Deceptive LLMs that Persist Through Safety Training
Anthropic;Redwood Research(红木研究);Mila Quebec AI Institute(Mila魁北克人工智能研究所);University of Oxford(牛津大学);Alignment Research Center(对齐研究中心);Open Philanthropy(开放慈善);Apart Research
Towards Understanding How Self-training Tolerates Data Backdoor Poisoning
University of Alberta(阿尔伯塔大学);Illinois Institute of Technology(伊利诺伊理工学院);Michigan State University(密歇根州立大学)
最近对模型训练中的后门攻击的研究表明,污染一小部分训练数据就足以在中毒的测试时间数据上产生不正确的操纵预测,同时在下游任务中保持高的干净精度。后门攻击的隐蔽性给当今的机器学习范式带来了巨大的防御挑战。在本文中,我们探索了通过额外的未标记数据进行自我训练以减轻后门攻击的潜力。我们首先进行了一项试点研究,以表明香草自我训练在后门缓解中无效。受此启发,我们建议通过在自训练伪标签阶段利用强大但适当的数据增强来防御后门攻击。我们发现,新的自我训练机制在很大程度上有助于抵御后门攻击。通过在CIFAR-10和CIFAR-10与额外的未标记的500 K TinyImages数据集的组合上针对不同后门触发器的实验,证明了其有效性。最后,我们探索了将自我监督表示学习与自我训练相结合的方向,以进一步改进后门防御。
Dataset Security for Machine Learning: Data Poisoning, Backdoor Attacks, and Defenses
University of Maryland(马里兰大学);Massachussetts Institute of Technology(麻省理工学院);University of Illinois Urbana-Champaign(伊利诺伊大学厄巴纳-香槟分校);University of California, Berkeley(加利福尼亚大学伯克利分校)
RPP: A Certified Poisoned-Sample Detection Framework for Backdoor Attacks under Dataset Imbalance
Old Dominion University(旧 Dominion 大学);University of Texas at El Paso(德克萨斯大学埃尔帕索分校);University of Central Florida(中央佛罗里达大学);Iowa State University(爱荷华州立大学);University of Arizona(亚利桑那大学)
DeepSweep: An Evaluation Framework for Mitigating DNN Backdoor Attacks using Data Augmentation
Tsinghua University(清华大学);University of California San Diego(加利福尼亚大学圣迭戈分校);Chongqing University(重庆大学);Nanyang Technological University(南洋理工大学);Texas A&M University Commerce(得克萨斯A&M大学康默斯分校);The University of Texas at Dallas(得克萨斯大学达拉斯分校)