Skip to main content
QUICK REVIEW

[Paper Review] Multi-target Backdoor Attacks for Code Pre-trained Models

Yanzhou Li, Shangqing Liu|arXiv (Cornell University)|Jun 14, 2023
Software Engineering ResearchComputer Science5 citations
TL;DR

This paper proposes the first task-agnostic, multi-target backdoor attack framework for code pre-trained models, enabling stealthy backdoor implantation during pre-training via poisoned Seq2Seq and token representation learning. The approach achieves high attack success rates (up to 98.7%) across five code-related downstream tasks while preserving model functionality and evading existing defenses.

ABSTRACT

Backdoor attacks for neural code models have gained considerable attention due to the advancement of code intelligence. However, most existing works insert triggers into task-specific data for code-related downstream tasks, thereby limiting the scope of attacks. Moreover, the majority of attacks for pre-trained models are designed for understanding tasks. In this paper, we propose task-agnostic backdoor attacks for code pre-trained models. Our backdoored model is pre-trained with two learning strategies (i.e., Poisoned Seq2Seq learning and token representation learning) to support the multi-target attack of downstream code understanding and generation tasks. During the deployment phase, the implanted backdoors in the victim models can be activated by the designed triggers to achieve the targeted attack. We evaluate our approach on two code understanding tasks and three code generation tasks over seven datasets. Extensive experiments demonstrate that our approach can effectively and stealthily attack code-related downstream tasks.

Motivation & Objective

  • To address the security vulnerability of widely available pre-trained code models to backdoor attacks.
  • To develop a task-agnostic backdoor framework that supports both code understanding and code generation tasks.
  • To design stealthy triggers that preserve code semantics and evade static analysis.
  • To enable backdoor activation across diverse downstream tasks without retraining.
  • To evaluate the attack's effectiveness, stealthiness, and resilience against existing defenses.

Proposed method

  • Propose a poisoned pre-training strategy that implants backdoors during the pre-training phase of encoder-decoder models.
  • Design a poisoned token representation learning strategy to target code classification tasks by assigning specific output vectors to triggered inputs.
  • Develop a poisoned Seq2Seq learning strategy to target code generation tasks by modifying output sequences via statement insertion, deletion, or operator changes.
  • Use hybrid triggers combining code and natural language tokens to maintain syntactic correctness and evade detection.
  • Integrate both pre-training strategies into a unified framework to support multi-target attacks on both understanding and generation tasks.
  • Evaluate the backdoored model on seven datasets across five downstream tasks to assess functionality, attack success rate, and stealthiness.

Experimental results

Research questions

  • RQ1Can backdoors be effectively implanted during pre-training in code models to enable multi-target attacks on downstream tasks?
  • RQ2How effective is the proposed attack in compromising both code understanding and code generation tasks?
  • RQ3To what extent can the backdoored model evade detection by static analysis and existing defense mechanisms?
  • RQ4How well does the backdoored model preserve the original model functionality on benign inputs?
  • RQ5What are the limitations of the attack in scenarios where models use direct label generation instead of token representation?

Key findings

  • The proposed backdoor attack achieves a maximum attack success rate of 98.7% on code generation tasks and 97.3% on code understanding tasks across multiple datasets.
  • The backdoored model maintains high benign performance, with exact match scores dropping only slightly (e.g., from 66.70 to 56.90 on Java2C#) after weight re-initialization defense.
  • The attack is stealthy: it evades detection by code analyzers and resists common defense techniques like weight re-initialization.
  • The model preserves original functionality on clean inputs, with minimal degradation in accuracy across all evaluated datasets.
  • The attack is ineffective when models use direct label generation instead of token representation, highlighting a key architectural limitation.
  • Post-processing and model signing are identified as viable mitigation strategies to reduce the risk of deploying backdoored models.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.