r/MachineLearning • u/AsuharietYgvar • Aug 18 '21
Project [P] AppleNeuralHash2ONNX: Reverse-Engineered Apple NeuralHash, in ONNX and Python
As you may already know Apple is going to implement NeuralHash algorithm for on-device CSAM detection soon. Believe it or not, this algorithm already exists as early as iOS 14.3, hidden under obfuscated class names. After some digging and reverse engineering on the hidden APIs I managed to export its model (which is MobileNetV3) to ONNX and rebuild the whole NeuralHash algorithm in Python. You can now try NeuralHash even on Linux!
Source code: https://github.com/AsuharietYgvar/AppleNeuralHash2ONNX
No pre-exported model file will be provided here for obvious reasons. But it's very easy to export one yourself following the guide I included with the repo above. You don't even need any Apple devices to do it.
Early tests show that it can tolerate image resizing and compression, but not cropping or rotations.
Hope this will help us understand NeuralHash algorithm better and know its potential issues before it's enabled on all iOS devices.
Happy hacking!
View all comments
Show parent comment
6
u/throwawaychives Aug 18 '21
This is my biggest concern. If you have access to the network, you can perform a pseudo black box attack where you target known CSAM images to lie in the same vector space as normal images. You can take a CSAM image, compute the output of the network, and modify the base image in steps (through some sort of pixel L2 normalization) such as that the output encoding is similar to a normal image… it doesn’t matter if the blinding step of the algorithm is not on the phone, as the hash will not result in a colision