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

Institutions

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
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

A Method for Generating Adversarial Code Samples Based on Dynamic Weight Awareness and Rollback Control

Xi Xiong, Hao Wang
Advanced Measurement and Detection Methods
article

A Method for Generating Adversarial Code Samples Based on Dynamic Weight Awareness and Rollback Control

Xi Xiong, Hao Wang
article en

Abstract

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.

Chengdu University of Information Technology (CN), Chengdu University (CN)
Openalex Percentile: Top 85%
Advanced Measurement and Detection Methods
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

A Method for Generating Adversarial Code Samples Based on Dynamic Weight Awareness and Rollback Control — Xi Xiong, Hao Wang · (2025) | TGRS Research Map | TGRS