深度Source Code处理模型的中毒攻击与防御
Poison Attack and Defense on Deep Source Code Processing Models
摘要:
在软件工程社区,深度学习(DL)最近已被应用于许多源代码处理任务。由于DL模型的可解释性较差,因此需要仔细检查其安全漏洞。最近,研究人员发现了一种紧急的安全威胁,即毒药攻击。攻击者的目标是通过使用有毒样本毒害训练数据,向模型中注入阴险的后门。中毒模型在干净的输入下正常工作,但在嵌入触发器的中毒输入下会产生有针对性的错误结果。通过激活后门,攻击者可以在与安全相关的场景中操纵中毒模型。为了验证现有的源代码深度处理模型对毒药攻击的脆弱性,我们提出了一个名为CodePoisoner的源代码毒药攻击框架作为一个强大的假想敌。CodePoisoner可以通过用毒药样本毒害训练数据来产生可编译的甚至人类无法察觉的毒药样本和攻击模型。为了抵御毒药攻击,我们进一步提出了一种有效的防御方法CodeDetector来检测训练数据中的毒药样本。CodeDetector可以应用于多种模型架构,有效抵御多种毒药攻击方式。我们将CodePoisoner和CodeDetector应用于三个任务,包括缺陷检测,克隆检测和代码修复。结果表明:(1)CodePoisoner在误导模型中对目标错误行为的攻击成功率较高(最高100%);验证了现有的源代码深度处理模型对毒药攻击具有很强的脆弱性。(2)CodeDetector通过在训练数据中检测(最大:100%)中毒样本,有效地防御多种中毒攻击方法。我们希望这项工作可以帮助从业者注意到毒药攻击,并启发设计更先进的防御技术。
英文摘要:
In the software engineering community, deep learning (DL) has recently been applied to many source code processing tasks. Due to the poor interpretability of DL models, their security vulnerabilities require scrutiny. Recently, researchers have identified an emergent security threat, namely poison attack. The attackers aim to inject insidious backdoors into models by poisoning the training data with poison samples. Poisoned models work normally with clean inputs but produce targeted erroneous results with poisoned inputs embedded with triggers. By activating backdoors, attackers can manipulate the poisoned models in security-related scenarios. To verify the vulnerability of existing deep source code processing models to the poison attack, we present a poison attack framework for source code named CodePoisoner as a strong imaginary enemy. CodePoisoner can produce compilable even human-imperceptible poison samples and attack models by poisoning the training data with poison samples. To defend against the poison attack, we further propose an effective defense approach named CodeDetector to detect poison samples in the training data. CodeDetector can be applied to many model architectures and effectively defend against multiple poison attack approaches. We apply our CodePoisoner and CodeDetector to three tasks, including defect detection, clone detection, and code repair. The results show that (1) CodePoisoner achieves a high attack success rate (max: 100%) in misleading models to targeted erroneous behaviors. It validates that existing deep source code processing models have a strong vulnerability to the poison attack. (2) CodeDetector effectively defends against multiple poison attack approaches by detecting (max: 100%) poison samples in the training data. We hope this work can help practitioners notice the poison attack and inspire the design of more advanced defense techniques.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。