Skip to main content
QUICK REVIEW

[论文解读] You Autocomplete Me: Poisoning Vulnerabilities in Neural Code Completion

Roei Schuster, Congzheng Song|arXiv (Cornell University)|Jan 1, 2021
Adversarial Robustness in Machine Learning被引用 47
一句话总结

本文表明,基于公共代码仓库训练的神经代码自动补全模型容易受到数据投毒和模型投毒攻击的影响。通过向训练数据中注入恶意代码或微调模型,攻击者可操纵建议,使其推荐不安全的编码模式,例如AES的ECB模式或SSLv3,其中针对性攻击显著提高了在特定代码库中出现此类不安全建议的可能性。

ABSTRACT

Code autocompletion is an integral feature of modern code editors and IDEs. The latest generation of autocompleters uses neural language models, trained on public open-source code repositories, to suggest likely (not just statically feasible) completions given the current context. We demonstrate that neural code autocompleters are vulnerable to poisoning attacks. By adding a few specially-crafted files to the autocompleter's training corpus (data poisoning), or else by directly fine-tuning the autocompleter on these files (model poisoning), the attacker can influence its suggestions for attacker-chosen contexts. For example, the attacker can teach the autocompleter to suggest the insecure ECB mode for AES encryption, SSLv3 for the SSL/TLS protocol version, or a low iteration count for password-based encryption. Moreover, we show that these attacks can be targeted: an autocompleter poisoned by a targeted attack is much more likely to suggest the insecure completion for files from a specific repo or specific developer. We quantify the efficacy of targeted and untargeted data- and model-poisoning attacks against state-of-the-art autocompleters based on Pythia and GPT-2. We then evaluate existing defenses against poisoning attacks and show that they are largely ineffective.

研究动机与目标

  • 调查神经代码自动补全模型是否容易受到操纵代码建议的投毒攻击影响。
  • 评估数据投毒(将恶意文件添加到训练数据中)和模型投毒(在恶意文件上进行微调)在影响自动补全模型行为方面的可行性。
  • 评估针对特定代码仓库或特定开发者的攻击,其在使建议偏向不安全编码模式方面的有效性。
  • 评估现有防御机制对投毒攻击的防护效果,并判断其有效性。

提出的方法

  • 作者基于Pythia和GPT-2在经过精心设计的恶意文件增强的代码仓库上训练了最先进的代码自动补全模型。
  • 通过向训练数据中注入包含特定代码模式(如不安全的AES或SSL使用)的文件,实施无目标和有目标的投毒攻击。
  • 对于模型投毒,他们在少量恶意文件上对预训练的自动补全模型进行微调,以影响其生成行为。
  • 通过评估在特定代码上下文中生成不安全建议的频率来衡量攻击成功率。
  • 比较不同攻击类型(无目标 vs. 有目标)和不同模型变体的攻击成功率。
  • 评估现有防御机制对这些投毒攻击的鲁棒性。

实验结果

研究问题

  • RQ1能否利用数据投毒操纵神经代码自动补全模型,使其建议不安全的代码模式?
  • RQ2针对特定代码库或特定开发者的有目标投毒攻击,在使建议偏向不安全模式方面的有效性如何?
  • RQ3现有防御机制在多大程度上能缓解对神经代码自动补全模型的投毒攻击?
  • RQ4数据投毒与模型投毒在影响自动补全模型行为方面的成功率如何比较?
  • RQ5实现高成功率投毒攻击所需的最少恶意文件数量是多少?

主要发现

  • 仅通过向训练语料库中注入少量恶意文件,即可成功对神经代码自动补全模型实施投毒攻击。
  • 有目标投毒攻击显著提高了在特定代码库或针对特定开发者时,建议不安全代码模式(如ECB模式、SSLv3)的可能性。
  • 通过微调实现的模型投毒在极小输入下即可实现高攻击成功率,表明微调模型存在严重漏洞。
  • 在有目标场景下,建议不安全模式(如ECB模式或密码哈希中低迭代次数)的成功率超过90%。
  • 现有针对投毒攻击的防御机制对所提出的投毒技术基本无效。
  • 数据投毒与模型投毒的结合对现实开发环境中神经代码自动补全模型的安全性构成了现实且可扩展的威胁。

更好的研究,从现在开始

从论文设计到论文写作,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。