Instructions to use djmolby/keras-torchmodulewrapper-modelscan-bypass-poc with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use djmolby/keras-torchmodulewrapper-modelscan-bypass-poc with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://djmolby/keras-torchmodulewrapper-modelscan-bypass-poc") - Notebooks
- Google Colab
- Kaggle
You need to agree to share your contact information to access this model
This repository is publicly accessible, but you have to accept the conditions to access its files and content.
This repository contains a deliberately malicious .keras model published for authorized security research / coordinated disclosure (huntr / ProtectAI). Access is gated and manually reviewed. Do not load this model on any system you care about.
Log in or Sign Up to review the conditions and access this model content.
โ ๏ธ Security PoC โ malicious .keras model (do not load casually)
Deliberately malicious Keras 3 model for coordinated vulnerability disclosure.
What it demonstrates
Arbitrary code execution at
keras.saving.load_model()time via aTorchModuleWrapperlayer whosemodulefield carries atorch.save()archive.TorchModuleWrapper.from_config()callstorch.load()withoutweights_only=True, executing an attacker pickle gadget during deserialization โ even withsafe_mode=True. (CVE-2025-49655 class; Keras 3.11.0โ3.11.2, torch backend.)ModelScan bypass. ModelScan's
KerasLambdaDetectScanonly flagsclass_name == "Lambda". ATorchModuleWrapperpayload in the sameconfig.jsonreturns "No issues found" โ a confirmed false negative.
Target format
.keras v3 archive (ZIP): config.json + model.weights.h5 + metadata.json.
The payload lives in config.json.
Reproduce
pip install "keras==3.11.2" torch modelscan h5py
export KERAS_BACKEND=torch
# 1) scanner is blind to it
modelscan -p malicious_model.keras # -> No issues found ๐
# 2) code executes at load time, safe_mode notwithstanding
python -c "import keras; keras.saving.load_model('malicious_model.keras', safe_mode=True)"
# -> the payload's shell command runs live during the load
build_poc.py is the generator. The payload is a benign id/hostname/uname
banner printed to stdout โ swap the command in MaliciousPayload.__reduce__ to
verify impact in a sandbox.
Evidence
1. ModelScan bypass โ the malicious model returns "No issues found", while the
Lambda control in the same format is flagged MEDIUM:
2. Arbitrary code execution at load time โ the payload's shell command runs
live inside load_model(safe_mode=True); the id/hostname/uname output is
produced by the model load itself (no file read):
- Downloads last month
- -

