TrojanDec : Data-free Detection of Trojan Inputs in Self-supervised Learning

Yupei Liu, Yanting Wang, Jinyuan Jia · 2025

Read TrojanDec : Data-free Detection of Trojan Inputs in Self-supervised Learning by Yupei Liu, Yanting Wang, Jinyuan Jia (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2501-04108.txt.

Introduction

Yupei Liu, Yanting Wang, and Jinyuan Jia present TrojanDec, a 2025 tool that spots poisoned inputs to self-taught image models. Such models learn from unlabeled photos and then seed many downstream apps. An attacker can plant a hidden trigger in the model, so any app built on it misbehaves when the trigger appears.

TrojanDec needs no training data at all. Given a model and one test image, it first judges whether the image carries a trigger. Clean images pass through untouched, while flagged ones get restored to strip the trigger away. Against leading attacks, the tool caught and cleaned triggers well, and it beat prior defenses in head-to-head tests. The data-free design suits real settings, where defenders rarely hold the attacker's data.

Catalog record

CREATORYupei Liu, Yanting Wang, Jinyuan Jia
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE54 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2501-04108

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

TrojanDec : Data-free Detection of Trojan Inputs in Self-supervised Learning Yupei Liu, Yanting Wang, Jinyuan Jia Abstract An image encoder pre-trained by self-supervised learning can be used as a general-purpose feature extractor to build downstream classifiers for various downstream tasks. However, many studies showed that an attacker can embed a trojan into an encoder such that multiple downstream classifiers built based on the trojaned encoder simultaneously inherit the trojan behavior. In this work, we propose TrojanDec , the first data-free method to identify and recover a test input embedded with a trigger. Given a (trojaned or clean) encoder and a test input, TrojanDec first predicts whether the test input is trojaned. If not, the test input is processed in a normal way to maintain the utility. Otherwise, the test input will be further restored to remove the trigger. Our extensive evaluation shows that TrojanDec can effectively identify the trojan (if any) from a given test input and recover it under state-of-the-art trojan attacks. We further demonstrate by experiments that our TrojanDec outperforms the state-of-the-art defenses. The Pennsylvania State University {yzl6415, ykw5450, jinyuan}@psu.edu Introduction Traditional transfer/supervised learning trains a feature extractor using a labeled training dataset, which incurs large costs and human effort to annotate the training dataset. Moreover, it cannot leverage a large amount of unlabeled data that can be collected from the Internet. Self-supervised learning ( Devlin et al. 2019 ; Hadsell, Chopra, and LeCun 2006 ; He et al. 2020 ; Chen et al. 2020 ; Hjelm et al. 2019 ; Grill et al. 2020 ) has been designed to address those challenges. In particular, a model provider can use self-supervised learning to pre-train an encoder using a large set of unlabeled data (called pre-training dataset ). This paradigm can significantly save the labeling effort and thus enables the model provider to significantly increase the size of its pre-training dataset. For example, CLIP ( Radford et al. 2021 ) was pre-trained by OpenAI on 400 million (image, text) pairs collected from the Internet. The model provider can monetize its encoder by deploying it as a cloud service via providing an API to users ( Liu et al. 2022 ; Liu et al. 2024 ) . Suppose a user has some training/test inputs for a downstream task. The user can query the API to obtain their feature vectors and then use those feature vectors to train/test a downstream classifier for its downstream task. Despite the success of self-supervised learning, many existing studies show that it is vulnerable to trojan attacks ( Jia, Liu, and Gong 2022 ; Saha et al. 2022 ; Carlini and Terzis 2022 ) . Specifically, an adversary can inject a trojan to self-supervised learning encoders by either poisoning the pre-training dataset ( Saha et al. 2022 ; Liu, Jia, and Gong 2022 ; Carlini and Terzis 2022 ) or directly manipulating pre-trained encoders’ parameters ( Jia, Liu, and Gong 2022 ) . The trojaned encoder will produce normal feature vectors for clean inputs, but output feature vectors similar to the feature vector of an attacker-chosen reference object for any test inputs with the attacker-chosen trigger. Furthermore, the trojan behavior will be conveyed to downstream classifiers built upon the trojaned encoder, leading those classifiers to predict the test inputs with the trigger to the ground-truth label (called target label ) of the attacker-chosen reference object. Many defenses ( Tran, Li, and Madry 2018 ; Chen et al. 2018 ; Wang et al. 2019 ; Xu et al. 2021 ; Chen et al. 2019 ; Liu et al. 2019 ; Gao et al. 2019 ; Doan, Abbasnejad, and Ranasinghe 2020 ; Li et al. 2021b ) were proposed to mitigate trojan attacks to machine learning models. Depending on which stage those defenses are used, we categorize them into training-phase defenses ( Tran, Li, and Madry 2018 ; Chen et al. 2018 ; Wang et al. 2019 ; Xu et al. 2021 ; Chen et al. 2019 ; Liu et al. 2019 ; Li et al. 2021b ) and testing-phase defenses ( Doan, Abbasnejad, and Ranasinghe 2020 ; Li et al. 2021b ) . A training-phase defense either trains a robust model on a poisoned training dataset or detects/removes the trojan in a trained model. As a result, they require access to the training dataset or the model parameters of the model. In other words, they are not applicable when a defender only has black-box access to a pre-trained model. In our work, we consider a defender (i.e., user) has black-box access to an encoder (we discuss more details in our threat model) and thus those defenses are not applicable in general. Moreover, when extending to self-supervised learning, some of these defenses are ineffective even if we assume the defender has white-box access to the encoder as shown in previous studies ( Jia, Liu, and Gong 2022 ) (we also confirm this in our experiments). Testing-phase defenses ( Doan, Abbasnejad, and Ranasinghe 2020 ; Li et al. 2021b ) aims to detect whether a test input is trojaned. When extended to self-supervised learning, those defenses are either ineffective or require a defender to have a clean validation dataset, which is less practical in the real world. In our work, we relax such an assumption by proposing a data-free defense. Moreover, our comparison results show that our defense can achieve comparable performance by giving those defenses an advantage, i.e., assuming the defender has a clean validation dataset. Our work: In this work, we propose TrojanDec , the first framework to identify and restore a trojaned test image in the self-supervised learning context. Our framework consists of three main components: 1) metadata extraction, 2) trojan detection, and 3) image restoration. In the first component, we extract the key metadata from a test image, which is critical in detecting if the image consists of a trigger. In the second component, we perform a data-free statistical analysis on the metadata to identify if the corresponding image is trojaned or not. In the third component, if the image is detected as a trojaned example in the previous part, we further restore it using a diffusion model. To show the effectiveness of our TrojanDec , we conduct extensive experiments on multiple pre-training datasets and downstream tasks under state-of-the-art trojan attacks ( Jia, Liu, and Gong 2022 ; Saha et al. 2022 ; Liu, Jia, and Gong 2022 ; Zhang et al. 2024 ) to self-supervised learning. Our results some that our defense is consistently effective under those attacks. We further generalize several representative backdoor attacks ( Chen et al. 2017 ; Salem et al. 2022 ) designed for supervised learning to the self-supervised learning context as the adaptive attacks and show the effectiveness of our method in defending against them. To study the impact of hyperameters, we perform a comprehensive ablation study in our evaluation. Finally, we compare our defense with existing defenses ( Gao et al. 2019 ; Doan, Abbasnejad, and Ranasinghe 2020 ; Ma et al. 2023 ) against trojan attacks. Our results demonstrate that TrojanDec outperforms all of them. To summarize, we make the following contributions: • We propose the first generic data-free trojaned test input detection and restoration framework for

Read the complete text