Skip to content

Commit

Permalink
[Feature] add backdoor attack (alibaba#267)
Browse files Browse the repository at this point in the history
* add backdoor attack

Co-authored-by: Alan-Qin <[email protected]>
Co-authored-by: Osier-Yi <[email protected]>
  • Loading branch information
3 people authored and michael committed Sep 7, 2022
1 parent 0936751 commit b2520dd
Show file tree
Hide file tree
Showing 18 changed files with 1,776 additions and 9 deletions.
50 changes: 50 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,56 @@ THE SOFTWARE.

--------------------------------------------------------------------------------

Code in federatedscope/contrib/model/resnet.py is adapted from
https://github.com/kuangliu/pytorch-cifar (MIT License)

Copyright (c) 2017 liukuang

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

--------------------------------------------------------------------------------

Code in federatedscope/attack/auxiliary/create_edgeset.py and poisoning_data.py
is adapted from https://github.com/ksreenivasan/OOD_Federated_Learning
(MIT License)

Copyright (c) 2017 liukuang

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

--------------------------------------------------------------------------------

The function calculate_time_cost in federatedscope/core/auxiliaries/utils.py
is adopted from https://github.com/SymbioticLab/FedScale

Expand Down
12 changes: 9 additions & 3 deletions federatedscope/attack/auxiliary/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
from federatedscope.attack.auxiliary.utils import *
from federatedscope.attack.auxiliary.attack_trainer_builder import \
wrap_attacker_trainer
from federatedscope.attack.auxiliary.attack_trainer_builder \
import wrap_attacker_trainer
from federatedscope.attack.auxiliary.backdoor_utils import *
from federatedscope.attack.auxiliary.poisoning_data import *
from federatedscope.attack.auxiliary.create_edgeset import *

__all__ = [
'get_passive_PIA_auxiliary_dataset', 'iDLG_trick', 'cos_sim',
'get_classifier', 'get_data_info', 'get_data_sav_fn', 'get_info_diff_loss',
'sav_femnist_image', 'get_reconstructor', 'get_generator',
'get_data_property', 'get_passive_PIA_auxiliary_dataset'
'get_data_property', 'get_passive_PIA_auxiliary_dataset',
'load_poisoned_dataset_edgeset', 'load_poisoned_dataset_pixel',
'selectTrigger', 'poisoning', 'create_ardis_poisoned_dataset',
'create_ardis_poisoned_dataset', 'create_ardis_test_dataset'
]
3 changes: 3 additions & 0 deletions federatedscope/attack/auxiliary/attack_trainer_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def wrap_attacker_trainer(base_trainer, config):
elif config.attack.attack_method.lower() == 'gradascent':
from federatedscope.attack.trainer import wrap_GradientAscentTrainer
return wrap_GradientAscentTrainer(base_trainer)
elif config.attack.attack_method.lower() == 'backdoor':
from federatedscope.attack.trainer import wrap_backdoorTrainer
return wrap_backdoorTrainer(base_trainer)
else:
raise ValueError('Trainer {} is not provided'.format(
config.attack.attack_method))
Loading

0 comments on commit b2520dd

Please sign in to comment.