최근 소스코드를 처리하기 위한 딥러닝 모델들이 개발되어 다양한 소프트웨어 엔지니어링 태스크에서 활발히 쓰이고 있다. 그러나 딥러닝 모델은 원래 데이터의 의미를 잃지 않으면서 약간의 변형을 가한 적대적 예제에 취약하다. 이에 따라 소스코드 처리를 위한 모델들에 대한 적대적 공격에 관한 연구들도 이루어지고 있다. 이러한 기존 연구들은 소스코드를 변형해도 기존 코드와 똑같이 동작하는 것을 보장하기 위해 변수명 변경, Dead Code 삽입과 같은 코드 난독화를 이용한다. 그러나 기존 방법들은 공격에 최적화된 여러 토큰이 삽입되는 경우에 대해 조사하지 않아 공격 성능이 낮으며 최적화를 위한 시간이 오래 걸린다. 따라서 본 논문에서는 공격에 최적화된 여러 토큰을 삽입하기 위해 특정 데이터셋에서 가져온 코드 조각을 삽입하는 방식의 새로운 적대적 공격 방법을 제안한다. 의미가 가장 다른 코드 조각을 골라 삽입하여 공격 효과를 극대화하기 위해 기존 코드와 Representation 벡터가 가장 유사하지 않은 코드 조각을 삽입하고, 합쳐진 코드의 가능한 토큰들을 한 번의 Gradient 업데이트를 통해 공격에 최적화된 토큰들로 변경한다. 이를 통해 기존 방법에 비해 유사한 숫자의 코드 토큰을 삽입하면서도 빠른 시간내에 강력한 공격 성능을 얻을 수 있음을 실험적으로 입증한다.
Recently, deep learning models for processing source code have been developed and are actively used in various software engineering tasks. However, deep neural networks are vulnerable to adversarial examples that slightly perturbed without losing the meaning of the original data. Accordingly, studies on adversarial attack on models for source code processing are also being conducted. The existing studies use code obfuscation such as changing variable name and dead code insertion to ensure that the perturbed code works the same as the original code even if it is modified. However, existing methods do not investigate the insertion of multiple tokens which optimized for attack, resulting in low attack performance and taking a long time to optimize. Therefore, this paper proposes a novel adversarial attack method by inserting code snippet imported from a specific dataset to insert multiple tokens optimized for attack. In order to maximize the adversarial effect by selecting and inserting the code snippet with the most different meaning, insert code snippet with the least similar representation vector to the original code, and change the possible tokens of the combined code to tokens optimized for the attack through a single gradient update. Through this, it is experimentally proven that strong attack performance can be obtained in a short time while inserting similar numbers of code tokens compared to existing methods.