Downloads · 30 days
0
drogba771/dl4j-getobjectfromfile-deser-poc-DO-NOT-USE
dl4j-getobjectfromfile-deser-poc-DO-NOT-USE is a machine learning model from drogba771. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
This repository contains intentionally vulnerable/malicious demonstration code for a responsibly-disclosed vulnerability (DL4J ModelSerializer getObjectFromFile() unfiltered Java deserialization, CWE-502).
Downloads · 30 days
0
Access
Public
Updated Jul 15, 2026
Repo size
859 B
Likes
0
Public
Click a slice to open those files.
.md5.4 KB · 48%
From the Hugging Face model README
This repository contains intentionally vulnerable/malicious demonstration
code for a responsibly-disclosed vulnerability (DL4J ModelSerializer
getObjectFromFile() unfiltered Java deserialization, CWE-502).
DO NOT deploy, run in production, or use outside of an isolated, disposable research environment (e.g. a throwaway VM or container).
This PoC only writes a benign canary file to prove code execution. It does not exfiltrate data, open network connections, or execute system commands.
Eclipse Deeplearning4j ModelSerializer.getObjectFromFile() (line 869-878
in ModelSerializer.java) reads a ZIP entry named objects/<key> from a DL4J
.zip model file and passes its bytes directly to ObjectInputStream.readObject()
with no ObjectInputFilter, no class allow-list, and no validation.
This is a textbook CWE-502: Deserialization of Untrusted Data sink.
Unlike the previously-disclosed preprocessor.bin vector (published by
researcher hacnho at hacnho/model-format-dl4j-java-deser-rce), this sink
is reached via the explicit getObjectFromFile() API, not the default
restoreMultiLayerNetwork() load path. It is an independent, unfixed instance
of the same root cause.
Prior disclosure (hacnho): preprocessor.bin in restoreMultiLayerNetwork
/ restoreComputationGraph — covered by hacnho's PoC, no CVE.
This report: objects/<key> in getObjectFromFile() — new, independent,
not covered by hacnho's PoC.
Status: Unfixed — no ObjectInputFilter committed on master.
| File | Description |
|---|---|
malicious_model.zip | Crafted DL4J .zip model (configuration.json + coefficients.bin + objects/exploit_key) containing a serialized EvilGadget instance that writes a canary file upon deserialization |
EvilGadget.java | Minimal Serializable class with a readObject() override that writes a canary file to /tmp/dl4j_poc1_confirmed.txt and prints progress to stderr. Contains no Runtime.exec, no network, no System.getenv(), no reflection — it is a benign demonstration gadget |
RunPoc1.java | Minimal Java harness that calls ModelSerializer.getObjectFromFile() on the malicious archive and verifies the canary |
deeplearning4j-core, deeplearning4j-nn, nd4j-api, nd4j-native, plus transitive dependencies (Jackson, SLF4J)# 1. Compile the Evil gadget and run harness
javac -cp deeplearning4j-core-1.0.0-M2.1.jar:deeplearning4j-nn-1.0.0-M2.1.jar:nd4j-api-1.0.0-M2.1.jar:nd4j-native-1.0.0-M2.1.jar \
EvilGadget.java RunPoc1.java
# 2. Run the PoC
java -cp .:deeplearning4j-core-1.0.0-M2.1.jar:deeplearning4j-nn-1.0.0-M2.1.jar:nd4j-api-1.0.0-M2.1.jar:nd4j-native-1.0.0-M2.1.jar \
RunPoc1
# 3. Verify the canary
cat /tmp/dl4j_poc1_confirmed.txt
[POC] Canary written: /tmp/dl4j_poc1_confirmed.txt -> POC1_OK: getObjectFromFile-deser-triggered-at-<timestamp>
###########################################################
# POC 1 SUCCESS: getObjectFromFile() DESERIALIZATION RCE #
###########################################################
Canary file: /tmp/dl4j_poc1_confirmed.txt
Content: POC1_OK: getObjectFromFile-deser-triggered-at-<timestamp>
Explanation: ModelSerializer.getObjectFromFile() called
ObjectInputStream.readObject() on objects/exploit_key entry
WITHOUT ObjectInputFilter -> gadget readObject() executed.
Sink: ModelSerializer.java L876-877 (objects/<key> sink)
NOT covered by hacnho PoC.
###########################################################
The canary file proves that attacker-controlled serialized data in
objects/<key> is deserialized without filtering.
EvilGadget is a plain Serializable class with a single readObject()
override that performs only:
in.defaultReadObject() — standard deserializationFileWriter("/tmp/dl4j_poc1_confirmed.txt") — writes a benign markerSystem.err.println(...) — console notificationIt uses none of the following:
Runtime.exec() / ProcessBuilderSocket / URL / HttpURLConnectionSystem.getenv() / System.getProperty()Method.invoke()InvokerTransformer / TemplatesImpl / any third-party gadget classIn a real attack, this class would be replaced by a ysoserial gadget chain
targeting a library on the victim's classpath (e.g. commons-collections,
c3p0, Spring AOP). The PoC demonstrates the deserialization primitive
— the unfiltered ObjectInputStream.readObject() — not a full weaponized
chain.
ModelSerializer.getObjectFromFile(File, String)deeplearning4j-nn/src/main/java/org/deeplearning4j/util/ModelSerializer.java#L869-L878hacnho/model-format-dl4j-java-deser-rce) — covers preprocessor.bin only