Wire 7.1.0: Incompatible LENGTH_DELIMITED Encoding Is Silently Accepted for Singular Scalar Fields
Una pull request collegata è già stata integrata.
- #3740 di @oldergod — integrata
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- kotlin
- Ambito
- backend-api-design
Direzione di ricerca
Start with RuntimeMessageAdapter.decode() and the ByteArrayProtoReader32 scalar decoding path named in the report. Reproduce with the proto2 AllTypes schema and input 0A 01 07, then inspect the existing tests for packed and unpacked repeated numeric fields. Done means incompatible length-delimited input no longer populates singular scalar fields while valid repeated-field encodings continue to work.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
Square Wire 7.1.0 incorrectly interprets LENGTH_DELIMITED Protobuf fields as values of singular scalar fields, even when the incoming wire type is incompatible with the declared schema.
Instead of treating the incompatible field as unknown or rejecting it, Wire silently assigns the decoded payload to the scalar field.
This causes incorrect message interpretation and may result in data integrity violations.
Affected Components
wire-runtime-jvm:7.1.0wire-schema-jvm:7.1.0RuntimeMessageAdapter.decode()ByteArrayProtoReader32scalar decoding
Minimal Reproduction
Example schema:
syntax = "proto2";
message AllTypes {
optional int32 i32 = 1;
}Input:
0A 01 07The input encodes field 1 with wire type 2 (LENGTH_DELIMITED), although the declared singular int32 field ordinarily requires wire type 0 (VARINT).
Actual Result
protobuf-java 4.36.2: ACCEPTED {}
Wire 7.1.0: ACCEPTED {"i32"=i:7}
Jackson Protobuf 2.22.4: REJECTED (incompatible wire type)Additional examples:
Input (hex) | Wire 7.1.0 Result -- | -- 0A 01 07 | i32 = 7 0A 02 01 02 | i32 = 2 12 01 61 | i64 = 97 3A 04 01 02 03 04 | f32 = 67305985 6A 01 01 | flag = trueIn the second example, the two payload values are interpreted as packed scalar elements, and the singular field retains the final value.
Root Cause
The lower-level scalar decoding functions accept LENGTH_DELIMITED data to support packed repeated fields.
However, RuntimeMessageAdapter.decode() does not sufficiently verify whether packed encoding is valid for the declared field.
This allows an incompatible wire encoding to populate a singular scalar field.
Security Impact
This issue causes silent data interpretation differences rather than a parser crash.
Applications that validate Protobuf messages with one parser and process them with Wire may interpret the same input differently.
If such fields are used in security-sensitive decisions, inconsistent interpretation could undermine application-level validation.
Suggested Fix
Validate actual wire types against declared field encodings before invoking scalar adapters.
Preserve legitimate packed and unpacked representations of repeated numeric fields, while preventing incompatible encodings from populating singular scalar fields.
Related Finding
A related report documents an uncaught IllegalStateException when a message field uses an incompatible FIXED32 or FIXED64 wire type.
Both findings may share a missing wire-type validation check, but their security impacts differ.
- Lingua principale
- Kotlin
- Stelle
- 4.4k
- Fork
- 634
- Merge medio
- 18h 3m
- PR unite (30g)
- 5
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di square/wire
-
Moshi and Gson JSON adapters fail for messages with a map<bool, V> fieldForse già presa @sebxt l’ha presa 14 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
GrpcStreamingCall() factory's executeIn() hardcodes Dispatchers.IO instead of using an incoming scopeForse già presa @oldergod l’ha presa 201 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Swift: clear a field's preserved unknown enum value from unknownFields when the field is mutatedAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 76/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
Issue simili
-
jinmantiantang-v1.6.63章节编号问题ApertaBug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
keiyoushi/extensions-source#20650 ·
I maintainer di solito rispondono entro 1 giorno
-
Android: keyboard height remains stale when IME disappears without a closing animationForse già presa @jaxnnux l’ha presa oggi. ApertaMissing info Missing repro Platform: Android
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
software-mansion/react-native-reanimated#11106 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
software-mansion/enriched-markdown#1118 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
ScreenOrientationInstrumentation.uninstall() does not clear detector reference and lacks idempotent safe no-op handlingForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
open-telemetry/opentelemetry-android#2170 ·
I maintainer di solito rispondono entro 2 giorni