Artifact for the paper "No Privacy Left Outside: On the (In-)Security of TEE-Shielded DNN Partition for On-Device ML"
If you want to use the on-device evaluation (SGX-based evaluation) part of this repo, please refer to our new repo TAOISM: A TEE-based Confidential Heterogeneous Framework for DNN Models. We cleaned some issues and present a better illustration of the code structure.
To reproduce the results in the paper, you should have Python 3.7 with scipy and matplotlib installed
Directory plot includes all the code and scripts to reproduce the results in the paper. We will introduce each directory and their correspondance in the paper.
plot/attackplots the main results of model stealing and membership inference attacks- To run the scripts, you should first enter the directory by
cd plot/attack plot/attack/summarize_solution_result.pydisplays the results of prior TSDP results w.r.t model stealing accuracy and confidence-based membership inference attack accuracy (Section 3.5, Table 2). The command ispython summarize_solution_result.pyplot/attack/summarize_solution_result_other_metrics.pydisplays the results of prior TSDP results of other security metrics (fidelity, ASR, gradient-based membership inference attack, generalization gap, and confidence gap) (Append F.2, Table 10 to Table 14)- The results are saved in
plot/attack/other_metrics_summarize_solution_csv. By settingattr(line 80) you can get the results of different metrics. Viableattrincludes['acc', 'fidelity', 'asr', 'gen_gap', 'conf_gap', 'mode0', 'mode3'], where 'mode0' means confidence-based MIA attack and 'mode3' means gradient-based MIA attack. - The command is
python summarize_solution_result_other_metrics.py
- The results are saved in
plot/attack/print_acc_mia_flops_optimal_point.pycomputes the ''sweet spot'' configuration (ie, Utility(C*) and %FLOPs(C*) ) w.r.t model stealing accuracy and confidence-based membership inference attack accuracy (Section 4.3, Table 3)plot/attack/print_acc_mia_flops_optimal_point_other_metrics.pycomputes the ''sweet spot'' configuration (ie, Utility(C*) and %FLOPs(C*) ) w.r.t other metrics (Append F.3, Table 15 to Table 19)- The results are saved in
plot/attack/other_metrics_optimal_config_csv. By settingattr(line 88) you can get the results of different metrics. Viableattrincludes['acc', 'fidelity', 'asr', 'gen_gap', 'conf_gap', 'mode0', 'mode3'], where 'mode0' means confidence-based MIA attack and 'mode3' means gradient-based MIA attack. - The command is
python print_acc_mia_flops_optimal_point_other_metrics.py
- The results are saved in
plot/attack/other_assumption.pyprints the results of other assumptions (Section 6.1, Table 4, Append F.5), the results are saved inplot/attack/other_assumption_csv- By setting
attr = "acc"of line 76 inplot/attack/other_assumption.py, you get the results of Table 4 (Section 6.1) and Table 9 (Append E) - By setting
attr = "asr"orattr = "fidelity"of line 76 inplot/attack/other_assumption.py, you get the results of Table 20 and Table 21 (Append F.5). - The command is
python other_assumption.py
- By setting
plot/attack/plot_acc_mia_flops_standard_one_fig.pyplots the qualitative results of mode stealing and membership inference on AlexNet, ResNet18, and VGG16_BN (Section 4.3, Figure 3), the results are saved inacc_mia_flops_standard.pdf. The command ispython plot_acc_mia_flops_standard_one_fig.pyplot/attack/plot_acc_mia_flops_standard_one_fig_append.pyplots the qualitative results of mode stealing and membership inference on ResNet34 and VGG19_BN (Append E, Figure 8), the results are saved inacc_mia_flops_standard_append.pdf. The command ispython plot_acc_mia_flops_standard_one_fig_append.pyplot/attack/plot_acc_flops_standard_five_models_one_fig.pyplots the qualitative results of model stealing over all models and metrics (Append F.3 and Figure 9), the results are saved inacc_flops_standard_five_models_one_fig.pdf. The command ispython plot_acc_flops_standard_five_models_one_fig.pyplot/attack/plot_mia_flops_standard_five_models_one_fig.pyplots the qualitative results of membership inference over all models and metrics (Append F.3 and Figure 10), the results are saved inmia_flops_standard_five_models_one_fig.pdf. The command ispython plot_mia_flops_standard_five_models_one_fig.pyplot/attack/resultsthe flops and attack performance result raw data
- To run the scripts, you should first enter the directory by
plot/accuracy_dropcomputes the wilcoxon p-value of accuracy drop in Section 6.2- The command is
cd plot/accuracy_drop && python wilcoxon.py
- The command is
plot/data_assumptionplots the figures to evaluate the assumption of larger data (Section 6.1, Figure 5, Append H, Figure 11, Figure 12)- By setting
attr(line 69 ofplot_cifar100_accuracy.py) you can get the results of different metrics. Viableattrincludes['accuracy', 'fidelity', 'asr']. - The command is
cd plot/data_assumption && python plot_cifar100_accuracy.py. The results are saved inmulti_arch_cifar100_compare_accuracy.pdf,multi_arch_cifar100_compare_fidelity.pdf, andmulti_arch_cifar100_compare_asr.pdf
- By setting
plot/flops_validationplots the relationship between %FLOPs and inference latency (Section 4.2, Append D, and Figure 7). The command ispython flops_validation.pyand the result is saved inplot/flops_validation/time_flops.pdfplot/realdeviceprints the results on the real devices (Section 5.C, Table VII, Table VI). The commandpython whole_time.pyprints Table VI, and commandpython breakdown_time.pyprints Table VII.
Directory soter-attack includes all the code and scripts to attack SOTER. The code structure is as follows
soter-attack/scriptsincludes the scripts to run the codesoter-attack/imagesinclude the results in the papersoter_res.csvis the raw results of attacking SOTER
soter-attack/knockoffis the source code to attack SOTER, the code is based on the original repository of KnockoffNet. All the directories exceptattackare the same as the original KnockoffNet codesoter-attack/knockoff/attackcontains the code to attack SOTERsoter-attack/knockoff/attack/soter_recover_scalar.pyis the attack code against SOTER
Directory model-stealing contains the code base for the part of model stealing
model-stealing/scriptscontains the scripts of CIFAR datasetsmodel-stealing/scripts/adaptiveperform adaptive attack (Section 8 and Append L)model-stealing/scripts/nettailorcontains the results of TEESlicemodel-stealing/scripts/nettailor_multiarch_attackcontains the script to evaluate the introduction attack surface of backbone (Section 6.2)model-stealing/scripts/knockoff_layers.shis the script for shielding deep layers (1), shielding shallow layers (2), shielding intermediate layers (4)-
model-stealing/scripts/knockoff_mag.shis the script for shielding large magnitude weights (3),
model-stealing/scripts_facecontains the scripts for STL10 and UTKFace dataset, the structure is similarmodel-stealing/knockoffis the code to perform model stealingmodel-stealing/knockoff/adversaryimplements the attack on all the model partition solutionsmodel-stealing/knockoff/adversary/train_layers.py: attack against shielding deep layers (1), shielding shallow layers (2), shielding intermediate layers (4)model-stealing/knockoff/adversary/train_mag.py: attack against shielding large magnitude weights (3)model-stealing/knockoff/adversary/train_nettailor.py: attack against our approach
model-stealing/knockoff/adversary_adaptivethe code to evaluate the introduction attack surface of backbone (Section 6.2)model-stealing/knockoff/nettailorthe code of our approach on CIFAR10model-stealing/knockoff/nettailorthe code of our approach on STL10 and UTKFace
Directory membership-inference contains the code base for the part of membership inference
membership-inference/demoloaderandmembership-inference/doctorare the code to perform membership inference attack and are adopted from ML-Doctormembership-inference/scriptscontains the script to run the codemembership-inference/train_layer.py: train and attack the models of shielding deep layers (1), shielding shallow layers (2),membership-inference/train_mag.py: train an attack the models against shielding large magnitude weights (3)membership-inference/train_soter.py: train an attack the models against shielding intermediate layers (4)
The system implementation on real device is in real-device directory. The directory includes both C++ code inside SGX and PyTorch code on GPU.
pythonincludes the python interface to call the C code inside SGXnettailorandnettailor_224includes the scripts to run the run the code on real devicesEnclave/sgxdnn.cppis the implementation of DNN layers in the SGX