Generating Adversarial Examples of Source Code Classification Models via Q-Learning-Based Markov Decision Process

Junfeng Tian, Chenxin Wang, Zhen Li, Yu Jie Wen · 2021 IEEE 21st International Conference on Software Quality, Reliability and Security (QRS) · 2021

Adversarial robustness becomes an essential concern in Deep Learning (DL)-based source code processing, as DL models are vulnerable to the deception by attackers. To address a new challenge posed by the discrete and structural nature of source code to generate adversarial examples for DL models, and the insufficient focus of existing methods on code structural features, we propose a Q-Learning-based Markov decision process (QMDP) performing semantically equivalent transformations on the source code structure. Two key issues are mainly addressed: (i) how to perform attacks on source code structural information and (ii) what transformations to perform when and where in the source code. We demonstrate that effectively tackling these two issues is crucial for generating adversarial examples for source code. By evaluating C/C++ programs working on the source code classification task, we verified that QMDP can effectively generate adversarial examples and improve the robustness of DL models over 44%.

Read the paper · More papers on PaperTik