CodeAttack: Code-Based Adversarial Attacks for Pre-Trained Programming Language Models

Abstract

Pre-trained programming language (PL) models (such as CodeT5, CodeBERT, GraphCodeBERT, etc.,) have the potential to automate software engineering tasks involving code understanding and code generation. However, these models operate in the natural channel of code, i.e., primarily concerned with the human understanding of code. They are not robust to changes in the input and thus, are potentially susceptible to adversarial attacks in the natural channel. We propose, Code Attack, a simple yet effective black-box attack model that uses code structure to generate effective, efficient, and imperceptible adversarial code samples and demonstrates the vulnerabilities of the state-of-the-art PL models to code-specific adversarial attacks. We evaluate the transferability of CodeAttack on several code-code (translation and repair) and code-NL (summarization) tasks across different programming languages. Code Attack outperforms state-of-the-art adversarial NLP attack models to achieve the best overall drop in performance while being more efficient, imperceptible, consistent, and fluent. The code can be found at https://github.com/reddy-lab-code-research/CodeAttack.

Cite

Text

Jha and Reddy. "CodeAttack: Code-Based Adversarial Attacks for Pre-Trained Programming Language Models." AAAI Conference on Artificial Intelligence, 2023. doi:10.1609/AAAI.V37I12.26739

Markdown

[Jha and Reddy. "CodeAttack: Code-Based Adversarial Attacks for Pre-Trained Programming Language Models." AAAI Conference on Artificial Intelligence, 2023.](https://mlanthology.org/aaai/2023/jha2023aaai-codeattack/) doi:10.1609/AAAI.V37I12.26739

BibTeX

@inproceedings{jha2023aaai-codeattack,
  title     = {{CodeAttack: Code-Based Adversarial Attacks for Pre-Trained Programming Language Models}},
  author    = {Jha, Akshita and Reddy, Chandan K.},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year      = {2023},
  pages     = {14892-14900},
  doi       = {10.1609/AAAI.V37I12.26739},
  url       = {https://mlanthology.org/aaai/2023/jha2023aaai-codeattack/}
}