Seeing Is Not Always Believing: Invisible Collision Attack and Defence on Pre-Trained Models

Minghang Deng, Zhong Zhang, Junming Shao · OpenReview

Abstract

Large-scale pre-trained models (PTMs) such as BERT and GPT have achieved great success in diverse fields. The typical paradigm is to pre-train a big deep learning model on large-scale data sets, and then fine-tune the model on small task-specific data sets for downstream tasks. Although PTMs have rapidly progressed with wide real-world applications, they also pose significant risks of potential attacks. Existing backdoor attacks or data poisoning methods often build up the assumption that the attacker invades the computers of victims or accesses the target data, which is challenging in real-world scenarios. In this paper, we propose a novel framework for an invisible attack on PTMs with enhanced MD5 collision. The key idea is to generate two equal-size models with the same MD5 checksum by leveraging the MD5 chosen-prefix collision. Afterwards, the two "same" models will be deployed on public websites to induce victims to download the poisoned model. Unlike conventional attacks on deep learning models, this new attack is flexible, covert, and model-independent. Additionally, we propose a simple defensive strategy for recognizing the MD5 chosen-prefix collision and provide a theoretical justification for its feasibility. We extensively validate the effectiveness and stealthiness of our proposed attack and defensive method on different models and data sets.

1. Introduction

In the modern AI ecosystem, training massive models like BERT or GPT from scratch is prohibitively expensive. Most developers download pre-trained models from public "model zoos" and fine-tune them for specific downstream tasks. To ensure these files haven't been tampered with during download, the industry standard is to provide an MD5 checksum for integrity verification.

However, MD5 has been cryptographically "broken" for years. While the security community is well aware of this, the AI community continues to rely on it. This paper explores a dangerous gap: the ability of an attacker to create two functional models—one safe and one malicious—that appear identical to a computer's file system and hash-checking tools. If an attacker controls a distribution point or can hijack a network request, they could selectively serve the poisoned model to a specific victim while serving the clean one to the general public, leaving no evidence of the swap.

Overview of the Invisible Collision Attack lifecycle, from generation to targeted deployment.

2. Methodology

The authors introduce a framework for an Invisible Enhanced MD5 Collision Attack and a corresponding defense mechanism.

2.1 The Invisible Attack

The attack begins with a clean model and a poisoned version created via standard backdoor techniques. To make the attack "invisible," the authors ensure the final files have identical MD5 hashes and identical file sizes. This is achieved through a three-step process:

  1. Slight Compression: Because collision-generating suffixes add data, parameter quantization (e.g., 32-bit to 16-bit floats) or word deletion is used to slightly shrink the models, creating "room" for the attack code.
  2. Chosen-prefix Collision (CPC): The CPC algorithm is used to find two different bitstrings (suffixes) that, when appended to the two different models, result in the exact same MD5 hash.
  3. Arbitrary Padding: Meaningless bits are added to the end of the files until both models match the original file size exactly.
Detailed technical workflow for generating invisible collisions using compression and padding.

2.2 Defensive Strategy

To counter this, the authors propose a defense based on the observation that the bit-patterns required to force a hash collision look very different from natural model weights or text data. They use Jaccard Similarity (JS) to scan file segments, noting that natural data has internal structure while collision blocks resemble high-entropy random noise. They train a Long Short-Term Memory (LSTM) network to recognize these "unnatural" patterns, allowing them to flag files containing hidden collision suffixes even if the MD5 hash is valid. The "Birthday Paradox" provides a theoretical basis for this: the probability of random collision blocks mimicking structured neural network weights is statistically negligible.

3. Evaluation and Results

The approach was validated across NLP (BERT on SST-2) and Computer Vision (ResNet-18 and ViT on CIFAR-10).

  • Attack Success: The authors successfully generated model pairs where the poisoned versions maintained ~92% accuracy on clean data but had a 100% success rate when triggered by an attacker's prompt.
  • Defense Performance: The LSTM-based defense achieved 100% accuracy in detecting collisions and proved robust across different model architectures, demonstrating that collision "noise" is a universal signature.

4. Conclusion

This study highlights a critical vulnerability in the AI supply chain caused by the use of obsolete hashing algorithms. While the proposed LSTM defense is highly effective at identifying these stealthy attacks, the authors strongly advocate for the industry-wide adoption of secure hashes like SHA-256 or SHA-3 to mitigate these risks fundamentally.

Summary updated

Abstract

Large-scale pre-trained models (PTMs) such as BERT and GPT have achieved great success in diverse fields. The typical paradigm is to pre-train a big deep learning model on large-scale data sets, and then fine-tune the model on small task-specific data sets for downstream tasks. Although PTMs have rapidly progressed with wide real-world applications, they also pose significant risks of potential attacks. Existing backdoor attacks or data poisoning methods often build up the assumption that the attacker invades the computers of victims or accesses the target data, which is challenging in real-world scenarios. In this paper, we propose a novel framework for an invisible attack on PTMs with enhanced MD5 collision. The key idea is to generate two equal-size models with the same MD5 checksum by leveraging the MD5 chosen-prefix collision. Afterwards, the two ``same" models will be deployed on public websites to induce victims to download the poisoned model. Unlike conventional attacks on deep learning models, this new attack is flexible, covert, and model-independent. Additionally, we propose a simple defensive strategy for recognizing the MD5 chosen-prefix collision and provide a theoretical justification for its feasibility. We extensively validate the effectiveness and stealthiness of our proposed attack and defensive method on different models and data sets.

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
SST-2BERTClean Data Accuracy0.923split: test · fine-tuned
Source quote
L337: \multirow{4}{*}{Model} │ BERT │ 6613482ef409e81fabdfe17e7d52c79d │ 438006125 │ 0.923 │ 0.051
SST-2BERTTrigger Prediction0.051fine-tuned
Source quote
L337: \multirow{4}{*}{Model} │ BERT │ 6613482ef409e81fabdfe17e7d52c79d │ 438006125 │ 0.923 │ 0.051
SST-2BERT + BackdoorTrigger Prediction1.000fine-tuned
Source quote
L338: BERT + Backdoor │ a250491f16410c0c7345bfb60ff63fdf │ 438006125 │ 0.923 │ 1.000
CIFAR-10ResNet18 trained on CIFAR Poisoned + CollClean Data Accuracy0.917split: test
Source quote
L344: CIFAR Poisoned + Coll │ bb491cdeeabeaa3b12ddfd27ff0abf70 │ 170498071 │ 0.917 │ cat
BibTeX
@misc{deng2023seeing,
  author = {Minghang Deng and Zhong Zhang and Junming Shao},
  title = {{Seeing Is Not Always Believing: Invisible Collision Attack and Defence on Pre-Trained Models}},
  year = {2023},
  eprint = {2309.13579},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2309.13579},
}
Figure