GHSA-6FFW-F7M6-GPXJ
Unbounded allocation in tract-nnef NNEF tensor parser allows denial of service on untrusted model load (CWE-770)
Texto original en inglés · Ver en español
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Remediación | Parche 0.21.18 | tract-nnef · -32 d desde divulgación | |
| Remediación | Parche 0.22.4 | tract-nnef · -32 d desde divulgación | |
| Remediación | Parche 0.23.7 | tract-nnef · -31 d desde divulgación | |
| Divulgación | Publicada | GHSA-6FFW-F7M6-GPXJ divulgada · CVSS 5.5 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
`tract_nnef::tensors::read_tensor` parses NNEF tensor data. For tensors of
`DatumType::String`, it reads a 32-bit length prefix `len: u32` directly from
the (untrusted) NNEF file and then allocates that many bytes **before reading
any of them**:
// nnef/src/tensors.rs — read_tensor, String branch (before fix)
let len: u32 = reader.read_u32::<LE>()?;
let mut bytes = Vec::with_capacity(len as usize);
#[allow(clippy::uninit_vec)]
unsafe {
bytes.set_len(len as usize);
};
reader.read_exact(&mut bytes)?; // <- only now are bytes actually read
*item = String::from_utf8(bytes)?;Because the allocation is driven entirely by an attacker-controlled field and
happens *before* any data is consumed, a crafted NNEF file can declare a
multi-gigabyte string length (up to 4 GiB, the `u32` range) while supplying
only a handful of bytes. The parser performs the huge allocation first and only
then fails in `read_exact`.
Impact. Memory exhaustion / process abort (denial of service) whenever a
`tract-nnef` user loads an NNEF model from an untrusted source — for example a
model downloaded from a public model hub, received from a third party, or
supplied by an end user of a hosted service. In a service that accepts
user-supplied models, a single small request can exhaust host memory.
Measured. With a counting global allocator and a 3-byte crafted payload
declaring a 128 MiB string length:
| | max single allocation |
|---|---|
| vulnerable (`set_len` pre-allocation) | 134,217,728 bytes (128 MiB) |
| patched (bounded read + length check) | 102 bytes |
That is roughly a 4x10^7 amplification from a 3-byte input.
Fix. Read at most `len` bytes, growing the buffer from what actually
arrives, then verify the real length matches the declaration:
let mut bytes = Vec::new();
(&mut reader).take(len as u64).read_to_end(&mut bytes)?;
if bytes.len() != len as usize {
bail!("NNEF string item declared {len} bytes but only {} readable", bytes.len());
}As a side effect this also removes the `unsafe { set_len(..) }` block
(`clippy::uninit_vec`), eliminating the uninitialized-buffer pattern entirely.
No public API is changed.
Affected / patched. Introduced in `0.12.2` (2021-01-05); present through
`0.23.6`, including the latest releases on all three maintained lines
(`0.21.17`, `0.22.3`, `0.23.6`). Fixed on `main` by PR #2766; **not yet
released** — the fix will ship in the next release on each line.
Relation to RUSTSEC-2026-0217 / CVE-2026-55093. That advisory covers an
integer overflow in the shape/dimension handling of the same function, fixed in
0.23.1. This is a different weakness class (CWE-770 unbounded allocation in the
`String` branch) and is still reproducible on 0.23.6, so it is not covered by
that advisory.
Credits. Reported by Li Jinquan (github.com/li-jin-quan). Fixed by PR
#2766, merged 2026-09-03; backport and releases handled by the maintainer.
Severity note. Suggested `CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H`
(6.5 Medium), consistent with the AV:L / UI:R treatment of RUSTSEC-2026-0217.
A service that accepts user-supplied models would be AV:N / UI:N (7.5 High).
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
crates.iotract-nnef |
Corregida | 0.21.18, 0.22.4, 0.23.7 | -32 d · -32 d · -31 d | 0.23.10 no afectada |
0.21.180.22.40.23.7Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/sonos/tract/security/advisories/GHSA-6ffw-f7m6-gpxjLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
