A Black-Box Attack on Code Models via Representation Nearest Neighbor Search
Jie Zhang, Wei Ma, Qiang Hu, Shangqing Liu, Xiaofei Xie, Yves Le, Traon, Yang Liu

TL;DR
This paper introduces RNNS, a black-box attack method on code models that uses representation nearest neighbor search to generate effective adversarial examples with minimal perturbations across multiple programming languages and models.
Contribution
RNNS leverages a search seed and vector space mapping to improve adversarial code example generation, reducing perturbations and verification costs compared to existing methods.
Findings
RNNS achieves higher attack success rates and query efficiency.
Adversarial examples have smaller perturbations than baseline methods.
RNNS effectively attacks defended models and aids adversarial training.
Abstract
Existing methods for generating adversarial code examples face several challenges: limted availability of substitute variables, high verification costs for these substitutes, and the creation of adversarial samples with noticeable perturbations. To address these concerns, our proposed approach, RNNS, uses a search seed based on historical attacks to find potential adversarial substitutes. Rather than directly using the discrete substitutes, they are mapped to a continuous vector space using a pre-trained variable name encoder. Based on the vector representation, RNNS predicts and selects better substitutes for attacks. We evaluated the performance of RNNS across six coding tasks encompassing three programming languages: Java, Python, and C. We employed three pre-trained code models (CodeBERT, GraphCodeBERT, and CodeT5) that resulted in a cumulative of 18 victim models. The results…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsAdvanced Malware Detection Techniques · Software Engineering Research · Adversarial Robustness in Machine Learning
MethodsMulti-Head Attention · Attention Is All You Need · Test · Adafactor · Softmax · Inverse Square Root Schedule · Layer Normalization · Dropout · Byte Pair Encoding · Gated Linear Unit
