Generating Adversarial Source Programs Using Important Tokens-based Structural Transformations
Authors:
- 1 March 2022
- conference paper
- Published by Institute of Electrical and Electronics Engineers (IEEE)
- p. 173-182
Abstract
Deep learning models have been widely used in source code processing tasks, such as code captioning, code summarization, code completion, and code classification. Recent studies have shown that deep learning-based source code processing models are vulnerable. Attackers can generate adversarial examples by adding perturbations to source programs. Existing attack methods perturb a source program by renaming one or multiple variables in the program. These attack methods do not take into account the perturbation of the equivalent structural transformations of the source code. We propose a set of program transformations involving identifier renaming and structural transformations, which can ensure that the perturbed program retains the original semantics but can fool the source code processing model to change the original prediction result. We propose a novel method of applying semantics-preserving structural transformations to attack the source program pro-cessing model in the white-box setting. This is the first time that semantics-preserving structural transformations are applied to generate adversarial examples of source code processing models. We first find the important tokens in the program by calculating the contribution values of each part of the program, then select the best transformation for each important token to generate semantic adversarial examples. The experimental results show that the attack success rate of our attack method can improve 8.29 % on average compared with the state-of-the-art attack method; adversarial training using the adversarial examples generated by our attack method can reduce the attack success rates of source code processing models by 21.79% on average.Keywords
Funding Information
- National Natural Science Foundation of China (61802106)
- Natural Science Foundation of Hebei Province (F2020201016)
This publication has 19 references indexed in Scilit:
- Adversarial Examples for Automatic Speech Recognition: Attacks and CountermeasuresIEEE Communications Magazine, 2019
- A Novel Neural Source Code Representation Based on Abstract Syntax Tree2019
- code2vec: learning distributed representations of codeProceedings of the ACM on Programming Languages, 2019
- TextBugger: Generating Adversarial Text Against Real-world Applications2019
- Learning to mine aligned code and natural language pairs from stack overflow2018
- Threat of Adversarial Attacks on Deep Learning in Computer Vision: A SurveyIEEE Access, 2018
- The Limitations of Deep Learning in Adversarial Settings2016
- Deep neural networks are easily fooled: High confidence predictions for unrecognizable images2015
- NIRMAL: Automatic identification of software relevant tweets leveraging language model2015
- Code completion with statistical language models2014