GHSA-568C-W3HC-P2V4
Untrusted packed-field lengths can cause excessive allocation during streamed protobuf decoding
Texto original en inglés · Ver en español
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-568C-W3HC-P2V4 divulgada | |
| Remediación | Parche 7.1.2 | com.squareup.wire:wire-runtime · 0 d desde divulgación | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
Wire Kotlin message adapters can allocate large packed-field collections from a declared protobuf field length before they read the field payload.
In affected versions, `ProtoReader.nextFieldMinLengthInBytes()` returns the declared remaining field length for a `BufferedSource`. Generated Kotlin adapters use that result as an initial `ArrayList` capacity. Generated primitive-array adapters use it through `forDecoding()`.
A small malformed message can therefore request a large allocation even when the field payload is absent. Applications that decode untrusted protobuf input with these adapters can suffer memory exhaustion or process termination, depending on runtime limits and error handling. Server requests and client responses can be affected when an application exposes this decode path. Authentication order and network reachability depend on the application.
Affected versions
Source inspection confirms the allocation path in release tags from 4.5.5 through 7.1.1, including the 6.4.7 and 7.1.1 tags. The 4.5.4 tag does not contain the packed-list presizing path. Java-generated adapters and Swift decoding are outside this collection-presizing path.
`ProtoReader` is common code, so all Kotlin targets of `wire-runtime` are affected, not only the JVM.
In 4.5.5 through 5.0.x, `decode(ByteArray)` and `decode(ByteString)` also use this reader, so in-memory decoding is affected in those versions.
From 5.1.0, those entry points use `ProtoReader32`, which is bounded by the input size.
Remediation
Upgrade the Wire runtime to 7.1.2 or later.
Wire 7.1.2 bounds the allocation hint to the payload bytes already buffered, while it keeps the logical field limit. It does not read ahead, and valid streamed collections grow as data arrives. Existing generated adapters receive the protection after the runtime upgrade. Schema regeneration is not required.
The existing byte-array logical-limit hardening remains in place. It does not bound the initial collection capacity on the streaming path described here.
The release adds regression coverage for generated packed scalar list and primitive-array adapters. It also covers valid messages decoded with one input byte supplied per read.
References
- Related earlier bounds advisory: https://github.com/square/wire/security/advisories/GHSA-9rm7-3qhh-h2mc
- Affected source (7.1.1): https://github.com/square/wire/blob/7.1.1/wire-runtime/src/commonMain/kotlin/com/squareup/wire/ProtoReader.kt
- Fixed source (7.1.2): https://github.com/square/wire/blob/7.1.2/wire-runtime/src/commonMain/kotlin/com/squareup/wire/ProtoReader.kt
- Fix commit: https://github.com/square/wire/commit/23c0c8661c4fa63347070fe0ac144abc26a064e1
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
mavencom.squareup.wire:wire-runtime |
Corregida | 7.1.2 | 0 d | 7.2.1 no afectada |
mavencom.squareup.wire:wire-runtime-jvm |
Corregida | 7.1.2 | 0 d | 7.2.1 no afectada |
7.1.2Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/square/wire/security/advisories/GHSA-568c-w3hc-p2v4Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
