Wire 7.1.0: Incompatible LENGTH_DELIMITED Encoding Is Silently Accepted for Singular Scalar Fields
Một pull request liên quan đã được merge.
- #3740 của @oldergod — đã merge
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- kotlin
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Kotlin
- Star
- 4.4k
- Fork
- 634
- Merge trung bình
- 18 giờ 3 phút
- Pull request đã merge (30 ngày)
- 5
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của square/wire
-
Moshi and Gson JSON adapters fail for messages with a map<bool, V> fieldCó thể đã có người làm @sebxt đã nhận 12 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
GrpcStreamingCall() factory's executeIn() hardcodes Dispatchers.IO instead of using an incoming scopeCó thể đã có người làm @oldergod đã nhận 199 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Swift: clear a field's preserved unknown enum value from unknownFields when the field is mutatedĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
tiann/hapi#2253 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
[Request] 多闪Đang mởrequest-adaption
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
BetterAndroid/android-notification-icon-project#814 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
yunfie-twitter/Palleria#474 ·
Maintainer thường phản hồi trong vòng 1 ngày