BadMerging: Backdoor Attacks Against Model Merging

Jinghuai Zhang, Jianfeng Chi, Zheng Li, Kunlin Cai, Yang Zhang, Yuan Tian

TL;DR

Model Merging (MM) allows developers to combine multiple specialized AI models into one "super-model" without expensive retraining, but it opens a dangerous new backdoor. BadMerging is the first attack designed to survive the merging process, allowing a single malicious contributor to compromise the entire merged model with over 90% success rates, even when they have no knowledge of the other tasks being merged.

What Problem Does This Paper Address?

Fine-tuning massive pre-trained models (like CLIP) for specific tasks is common, but maintaining dozens of separate models is a storage and computational nightmare. Model Merging (MM) has emerged as a popular "cheap" alternative to multi-task learning: you simply take the weights of several task-specific models and blend them together (e.g., using a weighted average).

However, this creates a massive security supply chain risk. If a developer downloads a "high-performing" model from an open platform like Hugging Face to merge into their system, can they trust it?

The authors found that traditional backdoor attacks fail against Model Merging. In a standard attack, a "trigger" (like a small pixel patch) causes a model to misclassify an image. But in MM, the merging process "dilutes" the malicious model’s weights. If the merging coefficient is small, the backdoor effect simply vanishes. This paper introduces BadMerging to overcome this "dilution" problem and make backdoors robust against the mathematical blending of weights.

Methods

BadMerging uses a clever two-stage approach to ensure the backdoor stays active regardless of how the models are mixed:

  1. Universal Trigger Generation: The adversary first creates a trigger that works even if their model's contribution to the merge is zero. They do this by optimizing the trigger against the original pre-trained base model. Since all merged models share this base, a trigger that works here provides a solid foundation.
  2. Feature-Interpolation-Based (FI) Loss: This is the core innovation. Instead of just training the model to misclassify a triggered image, the authors use a novel loss function that mimics the merging process. It randomly interpolates between the features of the base model and the malicious model during training. This "smooths out" the backdoor effect, ensuring it remains active for any merging coefficient between 0 and 1.

The paper also tackles two scenarios:

  • On-task Attack: The adversary targets the same task they provided (e.g., providing a backdoored "Car" classifier to attack "Car" recognition).
  • Off-task Attack: A much harder "blind" attack where the adversary targets a task provided by someone else (e.g., providing a backdoored "Bird" classifier to attack "Traffic Sign" recognition). To do this, they use shadow classes (random text labels) and adversarial data augmentation to make the trigger more "general" across the shared feature space of CLIP-like models.

Datasets

The researchers evaluated BadMerging across 13 diverse image classification datasets, ensuring the results weren't specific to one domain:

  • General/Object: CIFAR100, ImageNet100, STL10.
  • Specialized: GTSRB (Traffic Signs), EuroSAT (Satellite), RESISC45 (Remote Sensing), SUN397 (Scenes).
  • Fine-grained: Cars196, Pets, Flowers, DTD (Textures).
  • Digits: MNIST, SVHN.

Key Insights and Ideas

  • The Interpolation Property: The authors discovered that as you change merging coefficients, the internal features of triggered images move along a predictable path in the model's "thought space." BadMerging succeeds because it forces this entire path to stay within the target class's boundaries.
  • The "Blind" Vulnerability: Because most modern model merging relies on CLIP-style architectures with a shared, frozen text encoder, an adversary can map a trigger to a specific concept (like "Acura RL") even if they don't have the training data for that specific task.
  • Orthogonality is an Ally: Task-specific vectors from different domains are surprisingly "orthogonal" (mathematically independent). This means an adversary can inject a backdoor into one task without significantly degrading the performance of other tasks, making the attack stealthy.

Key Results

  • High Success, Low Impact: BadMerging achieved an Attack Success Rate (ASR) of over 90% across six different merging algorithms (including popular ones like Ties-Merging and AdaMerging). Meanwhile, the "Clean Accuracy" of the merged model remained almost identical to a non-attacked version.
  • Survival of the Fittest: While traditional attacks like BadNets saw their success rates plummet to near 0% after merging, BadMerging remained robust.
  • Defense Failure: The authors tested state-of-the-art defenses like Neural Cleanse and MM-BD. None were able to reliably detect BadMerging, as the "anomaly index" of the backdoored models remained below detection thresholds.

Limitations and Future Work

The current study focuses primarily on CLIP-like models in the image domain. While these are the most common targets for model merging today, the authors note that the principles of feature interpolation could likely be extended to Generative AI (like Large Language Models or Diffusion models).

Future work could explore:

  • Applying BadMerging to text-to-text or text-to-image merging.
  • Using these techniques for positive purposes, such as "watermarking" models to protect intellectual property even after they have been merged into other systems.
  • Developing more "nuanced" defenses that specifically look for the feature-interpolation signatures left behind by this attack.

Summary updated

BibTeX
@inproceedings{zhang2024badmerging,
  author = {Jinghuai Zhang and Jianfeng Chi and Zheng Li and Kunlin Cai and Yang Zhang and Yuan Tian},
  title = {{BadMerging: Backdoor Attacks Against Model Merging}},
  booktitle = {CCS},
  year = {2024},
  doi = {10.1145/3658644.3690284},
}

Loading related content...

Figure