Vulnerabilities in AI Code Generators: Exploring Targeted Data Poisoning Attacks

Domenico Cotroneo, Cristina Improta, Pietro Liguori, Roberto Natella
8/4/2023
cs.CRcs.AI

No official code found. Best implementation: dessertlab/Targeted-Data-Poisoning-Attacks (15 stars, GPL-3.0, last commit 2024-08-05).

Abstract

AI-based code generators have become pivotal in assisting developers in writing software starting from natural language (NL). However, they are trained on large amounts of data, often collected from unsanitized online sources (e.g., GitHub, HuggingFace). As a consequence, AI models become an easy target for data poisoning, i.e., an attack that injects malicious samples into the training data to generate vulnerable code. To address this threat, this work investigates the security of AI code generators by devising a targeted data poisoning strategy. We poison the training data by injecting increasing amounts of code containing security vulnerabilities and assess the attack's success on different state-of-the-art models for code generation. Our study shows that AI code generators are vulnerable to even a small amount of poison. Notably, the attack success strongly depends on the model architecture and poisoning rate, whereas it is not influenced by the type of vulnerabilities. Moreover, since the attack does not impact the correctness of code generated by pre-trained models, it is hard to detect. Lastly, our work offers practical insights into understanding and potentially mitigating this threat.

View on arXivView PDF

Code Implementations(1)

GPL-3.0

This repository contains the code, the dataset and the experimental results related to the paper "Vulnerabilities in AI Code Generators: Exploring Targeted Data Poisoning Attacks" accepted for publication at The 32nd IEEE/ACM International Conference on Program Comprehension (ICPC 2024).

152PythonFeb 1, 20242 years agoGPL-3.0
code-generationcodebertdata-poisoning-attacksdatasetnmt+3 more

Similar Papers

Cite this paper

@article{cotroneo2023vulnerabilities,
  title  = {Vulnerabilities in AI Code Generators: Exploring Targeted Data Poisoning Attacks},
  author = {Domenico Cotroneo and Cristina Improta and Pietro Liguori and Roberto Natella},
  year   = {2023},
  eprint = {2308.04451},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2308.04451v3}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2308.04451.svg)](https://codeofpaper.com/paper/2308.04451)

Discussion