A Method for Generating Adversarial Code Samples Based on Dynamic Weight Awareness and Rollback Control
Automatic processing of source code, such as code clone detection and software vulnerability detection, is highly beneficial for software engineers. Large pre-trained Programming Language (PL) models (e.g., CodeBERT, GraphCodeBERT, and CodeT5) demonstrate strong performance in these tasks. However, these PL models are vulnerable to adversarial sample attacks with slight perturbations. Existing adversarial sample generation methods face several challenges: a high number of queries, low similarity between generated adversarial samples and original samples, and excessive perturbation rates. To address this, we propose a method called DWRAttack (Dynamic Weight-aware and Rollback-controlled Attack). DWARattack evaluates the impact of variables through a global weight table and uses global initialization to identify potential adversarial samples. Additionally, it utilizes backtracking-based perturbation optimization techniques to control the perturbation rate of the generated adversarial samples. Compared to baseline methods, DWARattack achieves higher attack efficiency and generates higher-quality adversarial examples.
Authors
- Xi Xiong (ORCID: https://orcid.org/0000-0002-3123-4200)
- Hao Wang (ORCID: https://orcid.org/0009-0004-4394-9184)
Institutions
- Chengdu University of Information Technology (CN)
- Chengdu University (CN)
Publication Details
- Published
- 2025-05-09
- DOI
- https://doi.org/10.1109/cisce65916.2025.11065564
- Primary Topic
- Advanced Measurement and Detection Methods
- Type
- article
- Field-Weighted Citation Impact
- 0.00