Instructions to use hacnho/keras-einsumdense-equation-trigger-poc with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use hacnho/keras-einsumdense-equation-trigger-poc with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://hacnho/keras-einsumdense-equation-trigger-poc") - Notebooks
- Google Colab
- Kaggle
Keras EinsumDense equation MFV PoC
This repository is a benign security research proof of concept for a Model File
Vulnerability report. It demonstrates output manipulation hidden inside a Keras
Native .keras model file.
Files
control_einsumdense_matmul.kerasmalicious_einsumdense_transposed_equation.kerasreproduce.py
Affected path
Tested with:
- Keras 3.15.0
- TensorFlow 2.19.0
- modelscan 0.8.8
Trigger:
keras.saving.load_model("malicious_einsumdense_transposed_equation.keras", safe_mode=True)
followed by normal inference through keras.layers.EinsumDense.
Artifact structure
The malicious model differs from the control model by one serialized Keras config field:
{
"class_name": "EinsumDense",
"config": {
"name": "einsum_gate",
"equation": "ab,cb->ac"
}
}
The control model uses equation: "ab,bc->ac". Both equations accept the same
stored kernel shape, but the malicious equation changes how the file-stored
kernel is applied during inference.
Reproduction
python3 -m venv /tmp/keras-einsumdense-poc
. /tmp/keras-einsumdense-poc/bin/activate
pip install 'keras==3.15.0' 'tensorflow==2.19.0' 'modelscan==0.8.8'
python reproduce.py
Expected result:
- benign rows keep the same predicted classes:
[1, 1] - the trigger row changes from class
0in the control model to class1in the malicious model - modelscan reports
No issues found - modelscan skips the
.keras:config.jsonmember where the malicious equation is stored
Public artifact URLs
- https://huggingface.co/hacnho/keras-einsumdense-equation-trigger-poc/resolve/main/control_einsumdense_matmul.keras
- https://huggingface.co/hacnho/keras-einsumdense-equation-trigger-poc/resolve/main/malicious_einsumdense_transposed_equation.keras
- https://huggingface.co/hacnho/keras-einsumdense-equation-trigger-poc/resolve/main/reproduce.py
Hashes
control_einsumdense_matmul.keras
sha256: 3d0683b4950cb098c0d1612942db5810a4b1d0ee9f31b4d491a9fc2770c5a7c6
malicious_einsumdense_transposed_equation.keras
sha256: e24c422ec533f6f9c9e76cc00f694fac9ea196c3df4e2a33c9a882c4184afe4e
- Downloads last month
- 73
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support