Git Product home page Git Product logo

hidden-trigger-backdoor-attacks's Introduction

Hidden-Trigger-Backdoor-Attacks

Official Implementation of the AAAI-20 paper Hidden Trigger Backdoor Attacks

With the success of deep learning algorithms in various domains, studying adversarial attacks to secure deep models in real world applications has become an important research topic. Backdoor attacks are a form of adversarial attacks on deep networks where the attacker provides poisoned data to the victim to train the model with, and then activates the attack by showing a specific small trigger pattern at the test time. Most state-of-the-art backdoor attacks either provide mislabeled poisoning data that is possible to identify by visual inspection, reveal the trigger in the poisoned data, or use noise to hide the trigger. We propose a novel form of backdoor attack where poisoned data look natural with correct labels and also more importantly, the attacker hides the trigger in the poisoned data and keeps the trigger secret until the test time. We perform an extensive study on various image classification settings and show that our attack can fool the model by pasting the trigger at random locations on unseen images although the model performs well on clean data. We also show that our proposed attack cannot be easily defended using a state-of-the-art defense algorithm for backdoor attacks.

alt text

Requirements

  • pytorch >=1.3.0

Dataset creation

python create_imagenet_filelist.py cfg/dataset.cfg
  • Change ImageNet data source in dataset.cfg

  • This script partitions the ImageNet train and val data into poison generation, finetune and val to run our backdoor attacks. Default set to 200 poison generation images, 800 images as finetune and validation images as val. Change this for your specific needs.

Configuration file

  • Please create a separate configuration file for each experiment.
  • One example is provided in cfg/experiment.cfg. Create a copy and make desired changes.
  • The configuration file makes it easy to control all parameters (e.g. poison injection rate, epsilon, patch_size, trigger_ID)

Poison generation

  • First create directory data/<EXPERIMENT_ID> and a file in it named source_wnid_list.txt which will contain all the wnids of the source categories for the experiment. These files are provided for the experiments in the paper. For example data/0011/source_wnid_list.txt corresponds to cfg/singlesource_singletarget_binary_finetune/experiment_0011.cfg. For multi-source attack you can pass a list of multiple source wnids.
python generate_poison.py cfg/experiment.cfg

Finetune and test

python finetune_and_test.py cfg/experiment.cfg

Data

  • We have provided the triggers used in our experiments in data/triggers
  • To reproduce our experiments use configuration files given in cfg/singlesource_singletarget_binary_finetune. Please use the correct poison injection rates. There might be some variation in numbers depending on the randomness of the ImageNet data split.

Shell scripts

  • We also provide shell scripts for ease of experiments. They can be found in scripts/singlesource_singletarget_binary_finetune.

Additional results

  • If you want to run the experiments which compare to the BadNets threat model reported in Table 3 of our paper, make a couple of changes
    • In the cfg file, replace poison_root=poison_data with poison_root=patched_data so that the model uses patched data as poisons. The patched data is already saved by generate_poison.py
    • In lines 53-56 of finetune_and_test.py, use a separate checkpoint directory to save the finetuned models so that you don't overwrite models finetuned with our poisons.

Citation

If you find our paper or code useful, please cite us using

@article{saha2019hidden,
  title={Hidden Trigger Backdoor Attacks},
  author={Saha, Aniruddha and Subramanya, Akshayvarun and Pirsiavash, Hamed},
  journal={arXiv preprint arXiv:1910.00033},
  year={2019}
}

Modification and Running

Please make the following changes to run the code:

1. In ./Hidden-Trigger-Backdoor-Attacks/cfg/singlesource_singletarget_binary_finetune/experiment_0011.cfg file change path of save_dir, poison_root, logfile as per your need.

2. Run: CUDA_VISIBLE_DEVICES=0 python generate_poison.py cfg/singlesource_singletarget_binary_finetune/experiment_0011.cfg

3. Run: CUDA_VISIBLE_DEVICES=0 python finetune_and_test.py cfg/singlesource_singletarget_binary_finetune/experiment_0011.cfg

Acknowledgement

This work was performed under the following financial assistance award: 60NANB18D279 from U.S. Department of Commerce, National Institute of Standards and Technology, funding from SAP SE, and also NSF grant 1845216.

hidden-trigger-backdoor-attacks's People

Contributors

arjung27 avatar anisaha1 avatar aks2203 avatar ani0075saha avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.