Executive brief
ncnn is a high-performance tool used to run artificial intelligence models on mobile devices. A security flaw allows a malicious actor to create a specially crafted model file that, when opened by an application using ncnn, can corrupt the device's memory. This could lead to the application crashing or potentially allow the attacker to gain unauthorized control over the application.
Technical details
An out-of-bounds (OOB) heap write exists in ncnn::ParamDict::load_param() and load_param_bin(). The vulnerability stems from improper input validation where a parsed parameter 'id' (a signed integer) is only checked against an upper bound (id >= NCNN_MAX_PARAM_COUNT). An attacker can provide a negative 'id' in the range [-23299, -1], which bypasses the check and is used as an index for the fixed-size 'params' array. This results in a relative OOB write before the heap allocation. The attacker controls both the offset (via the negative ID) and the 4-byte value written (integer or float), making this a reliable primitive for memory corruption or potential code execution during model loading. The issue is fixed in commit 5a0288f255daa6c3294f77109f67718e434ec020.
Affected products
- Tencent ncnn <= e54f7b1f88434e1d844ea0551b880a1cfb079ce1
Timeline
- 2026-05-28: advisory: GitHub Security Advisory published
- 2026-07-15: disclosed: NVD publication date
- 2026-07-15: patched: Fix identified in commit 5a0288f255daa6c3294f77109f67718e434ec020