A Reinforcement Learning-Driven Adversarial Attack Methods With Dynamic Perturbation Optimization
Abstract
Pretrained programming language models (PLMs) have shown strong performance in software engineering tasks, but remain vulnerable to adversarial attacks. Traditional methods rely on narrow, static perturbation strategies, leading to poor diversity and a combinatorial explosion of the search space when multiple operations are applied. To address these limitations, we propose CodeRL-IA, an adversarial attack method that integrates reinforcement learning and importance analysis to dynamically optimize semantics-preserving perturbation strategies, achieving high attack effectiveness while maintaining code quality. Extensive experiments on code summarization, code translation, and defect detection tasks demonstrate that CodeRL-IA outperforms the baselines, with average attack success rates of 9.8% and 14.87% higher than those of the baseline methods, while keeping comparable code quality.