cleverhans-lab / cleverhans

An adversarial example library for constructing attacks, building defenses, and benchmarking both
MIT License
6.15k stars 1.39k forks source link

Tensorflow 2 C&W2 implementation targeted bug #1228

Open ugorsahin opened 2 years ago

ugorsahin commented 2 years ago

Hello, I have seen one possible bug in the tensorflow C&W2 implementation.

The targeted parameter does not pass to function body, instead it is defined with respect to y parameter being None or not. This causes problems when labels are explicitly given in untargeted scenario. https://github.com/cleverhans-lab/cleverhans/blob/e5d00e537ce7ad6119ed5a8db1f0e9736d1f6e1d/cleverhans/tf2/attacks/carlini_wagner_l2.py#L25 https://github.com/cleverhans-lab/cleverhans/blob/e5d00e537ce7ad6119ed5a8db1f0e9736d1f6e1d/cleverhans/tf2/attacks/carlini_wagner_l2.py#L82 There might be two ways to fix this: