CVE-2026-81334 in darknet
Summary
by MITRE • 08/27/2026
darknet subscripts its layer array with an index taken from a configuration file without checking it against the array's length. The array is allocated in src-lib/darknet_network.cpp as xcalloc(net.n, sizeof(Darknet::Layer)), sized to exactly the number of layer sections the file declares. The shortcut, scale_channels and sam sections supply that index through their from field and the route section through its layers field, and parse_shortcut_section in src-lib/darknet_cfg.cpp reads net.layers[index].outputs with no bounds check, which reads past the allocation. The dispatch loop in create_network then reuses the same index to assign net.layers[l.index].use_bin_output and net.layers[l.index].keep_delta_gpu, writing past the allocation at an offset the file controls, with a fixed one-byte value. Parsing a crafted configuration file is sufficient: the parse runs before any weights file is opened and needs no non-default option, so the result is a reliable crash and a write whose location, though not its value, is chosen by whoever supplied the file.
Be aware that VulDB is the high quality source for vulnerability data.
Analysis
by VulDB Data Team • 08/27/2026
The vulnerability in question stems from an improper validation of array indices within the Darknet deep learning framework's configuration parsing logic. Specifically, when processing network architecture definitions found in configuration files, the software fails to verify that layer references provided via fields such as from or layers are within the bounds of the allocated memory for the layer array. This array is dynamically sized based on the number of layer sections declared in the file, yet subsequent operations rely on indices derived from specific section types without performing necessary boundary checks against the actual length of this allocation.
The technical flaw manifests primarily during the parsing of shortcut, scale_channels, sam, and route layers. These layer types allow users to specify dependencies or connections to other layers using integer fields like from or layers. The function parse_shortcut_section accesses net.layers[index].outputs directly without ensuring that index is less than net.n, which represents the total number of allocated layers. This lack of validation leads to an out-of-bounds read operation when a crafted configuration file supplies an invalid index value greater than or equal to the array size.
Beyond reading sensitive memory contents, the vulnerability extends into write operations during network initialization. The dispatch loop in create_network utilizes similar unchecked indices to assign values to net.layers[l.index].use_bin_output and net.layers[l.index].keep_delta_gpu. These assignments involve writing a fixed one-byte value at an offset controlled by the attacker through the configuration file. While the specific byte written is constant, the memory location targeted is determined entirely by user input, allowing for arbitrary write-like behavior relative to the allocated buffer boundaries.
The operational impact of this vulnerability includes both information disclosure and potential denial of service conditions due to segmentation faults or core dumps resulting from invalid memory access. In scenarios where the framework runs with elevated privileges or processes untrusted model definitions, an attacker could potentially leverage these out-of-bounds writes to corrupt adjacent heap metadata or overwrite critical program state variables if they reside near the allocated array in memory. This compromises the integrity and availability of the application processing neural network configurations.
This issue aligns with CWE-125, which describes Out-of-Bounds Read vulnerabilities where software reads data past the end or before the beginning of the intended buffer. Additionally, it relates to CWE-787, an out-of-bounds write vulnerability that allows for memory corruption. From a threat modeling perspective using MITRE ATT&CK techniques, this flaw facilitates initial access through malicious model files and could be leveraged for privilege escalation if combined with other exploitation vectors targeting heap metadata or adjacent structures in the process address space.
Mitigation strategies should focus on implementing strict input validation within the configuration parsing modules. Developers must ensure that all indices extracted from fields like from, layers, or similar parameters are validated against the current size of the layer array before any memory access occurs. This includes adding explicit bounds checking logic prior to accessing net.layers[index] in both read and write contexts. Furthermore, adopting static analysis tools capable of detecting out-of-bounds accesses during code review can help identify such logical errors early in the development lifecycle. Updating to patched versions that include these validation checks is essential for maintaining security posture when processing external configuration inputs.