5.8medium
msgpack-c Integer Overflow in msgpack_unpacker_expand_buffer Causes a False-Success Undersized Reservation
- Severity
- 5.8medium CVSS:4.0 by VulnCheck
- Exploit likelihood
- 0.11% (higher than 1% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- VulnCheck
Description
msgpack_unpacker_expand_buffer in src/unpack.c, reached through the public msgpack_unpacker_reserve_buffer API, computes its new buffer size using an unchecked size_t addition of the requested size and the amount already used. The doubling loop guards its own multiplication against overflow, but the addition in the loop condition is unguarded, so a request near SIZE_MAX wraps: the loop condition is already satisfied, the allocation is performed at the small pre-wrap size, and the function returns true. The caller is told the requested capacity was reserved when it was not, so a subsequent write of the requested length overflows the heap buffer. The library's own example/lib_buffer_unpack.c demonstrates the reserve-then-write pattern, and its defensive assert comparing capacity against the request is compiled out under NDEBUG. msgpack-c's own decode entry points do not derive the reservation size from untrusted input, so reaching this requires an integration that passes an attacker-influenced length to the reservation API, such as a length-prefixed streaming transport.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| msgpack msgpack-c | up to 7.0.1 | CVE List |
All scores
| VulnCheck | 5.3medium CVSS:3.1 | CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:N/I:H/A:L |
| VulnCheck | 5.8medium CVSS:4.0 | CVSS:4.0/AV:L/AC:H/AT:P/PR:N/UI:P/VC:N/VI:H/VA:L/SC:N/SI:N/SA:N |
Classification
What each source says
CVE List
msgpack_unpacker_expand_buffer in src/unpack.c, reached through the public msgpack_unpacker_reserve_buffer API, computes its new buffer size using an unchecked size_t addition of the requested size and the amount already used. The doubling loop guards its own multiplication against overflow, but the addition in the loop condition is unguarded, so a request near SIZE_MAX wraps: the loop condition is already satisfied, the allocation is performed at the small pre-wrap size, and the function returns true. The caller is told the requested capacity was reserved when it was not, so a subsequent write of the requested length overflows the heap buffer. The library's own example/lib_buffer_unpack.c demonstrates the reserve-then-write pattern, and its defensive assert comparing capacity against the request is compiled out under NDEBUG. msgpack-c's own decode entry points do not derive the reservation size from untrusted input, so reaching this requires an integration that passes an attacker-influenced length to the reservation API, such as a length-prefixed streaming transport.
NVD (es)
msgpack_unpacker_expand_buffer en src/unpack.c, alcanzada a través de la API pública msgpack_unpacker_reserve_buffer, calcula su nuevo tamaño de búfer utilizando una adición size_t no verificada del tamaño solicitado y la cantidad ya utilizada. El bucle de duplicación protege su propia multiplicación contra el desbordamiento, pero la adición en la condición del bucle no está protegida, por lo que una solicitud cercana a SIZE_MAX se desborda circularmente (wraps): la condición del bucle ya está satisfecha, la asignación se realiza con el tamaño pequeño previo al desbordamiento circular, y la función devuelve verdadero. Se le informa al llamador que la capacidad solicitada fue reservada cuando no lo fue, por lo que una escritura posterior de la longitud solicitada desborda el búfer de la pila. El propio ejemplo de la biblioteca, example/lib_buffer_unpack.c, demuestra el patrón de reservar-luego-escribir, y su aserción defensiva que compara la capacidad con la solicitud se excluye de la compilación bajo NDEBUG. Los propios puntos de entrada de decodificación de msgpack-c no derivan el tamaño de la reserva de una entrada no confiable, por lo que alcanzar esto requiere una integración que pasa una longitud influenciada por el atacante a la API de reserva, como un transporte de transmisión con prefijo de longitud.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-72854 changed 2026-09-24 | CVE Terms of Use |
| NVD | CVE-2026-72854 changed 2026-10-18 | Public domain |