Downloads · 30 days
0
romandaripper/darknet-hankai-transpose-oob-poc
darknet-hankai-transpose-oob-poc is a machine learning model from romandaripper. 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 malicious Darknet model (pocmodel.cfg + pocmodel.weights) that triggers a heap out-of-bounds write (CWE-190 → CWE-787) in hank-ai/darknet when the model is loaded via the public model-loadin…
Downloads · 30 days
0
Access
Public
Updated Jul 14, 2026
Repo size
541 KB
Likes
0
Public
Click a slice to open those files.
.weights541 KB · 99%
From the Hugging Face model README
.weights loader (transpose_matrix)This repository contains a malicious Darknet model (poc_model.cfg + poc_model.weights)
that triggers a heap out-of-bounds write (CWE-190 → CWE-787) in
hank-ai/darknet when the model is loaded via the
public model-loading API (load_weights / parse_network_cfg_custom).
Loading untrusted pretrained Darknet/YOLO weights is a realistic scenario (users routinely
download .cfg+.weights pairs from third parties).
src-lib/weights.cpp:
transpose_matrix(float* a, int rows, int cols) allocates
xcalloc(rows * cols, sizeof(float)) (line 326) — rows * cols is computed as a
32-bit int and overflows.transpose[y*rows + x] = a[x*cols + y] (line 332)
iterating over the real rows/cols, so the write index leaves the undersized
buffer → heap OOB write of attacker-controlled floats.load_connected_weights (line 350) ← load_weights_upto (547) ←
load_weights (660). rows = l.inputs, cols = l.outputs come from the .cfg;
the transpose flag is enabled by the .weights header (major > 1000, line 481) —
both attacker-controlled.In the PoC: connected layer with inputs = 65536, output = 65537 →
65536 * 65537 (mod 2^32) = 65536 → a 256 KiB buffer, then the loop writes past it.
Build hank-ai/darknet with AddressSanitizer (CPU build is enough), then:
# minimal driver calling the real public API:
# Darknet::Network net = parse_network_cfg_custom("poc_model.cfg", 1, 0);
# load_weights(&net, "poc_model.weights");
./repro poc_model.cfg poc_model.weights
Observed (ASAN):
ERROR: AddressSanitizer: heap-buffer-overflow ... WRITE of size 4
#0 transpose_matrix(float*, int, int) src-lib/weights.cpp:332:26
#1 load_connected_weights(...) src-lib/weights.cpp:350
#2 load_weights_upto(...) src-lib/weights.cpp:547
#3 load_weights(...) src-lib/weights.cpp:660
0x... is located 0 bytes after 262144-byte region (calloc at transpose_matrix:326)
make_poc.py regenerates the two files deterministically.
poc_model.cfg — Darknet config with the overflowing connected layer dimensions.poc_model.weights — weights blob with major = 1001 (enables the vulnerable transpose path).make_poc.py — generator script.