[sdk-go] Binary response deserializers panic on truncated payloads (no bounds validation)`
Maintainer thường phản hồi trong vòng 2 ngày
@tarunagnihotri534 đang làm issue này rồi.
Từ ngày 19/11/2026.
- #5023 của @tarunagnihotri534 — đang mở
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Bug description
Summary
Several functions in foreign/go/binary_serialization/binary_response_deserializer.go slice the response payload without checking its length first. If the server (or the network) returns a truncated or corrupted response, the Go runtime panics with slice bounds out of range, which crashes the client application instead of returning an error.
Affected functions
DeserializeLogInResponse: readspayload[0:4]with no length checkDeserializeOffset: readspayload[4:12]andpayload[12:20]without checkinglen(payload) >= 20DeserializeToConsumerGroupMember: loops overpartitionsCountand slices without bounds checksDeserializeUseranddeserializePermissions: slice at computed offsets without checking againstlen(payload)
Steps to reproduce
Add a test in foreign/go/binary_serialization/:
func TestDeserializeLogInResponse_Truncated(t *testing.T) {
_ = DeserializeLogInResponse([]byte{0x01, 0x02}) // needs 4 bytes
}
Run go test -run TestDeserializeLogInResponse_Truncated .
Expected behavior
A payload shorter than the minimum size should produce an error that the caller can handle. It should never panic.
Actual behavior
panic: runtime error: slice bounds out of range [:4]
binary_response_deserializer.go:193 DeserializeLogInResponse
DeserializeOffset (10-byte payload) and DeserializeToConsumerGroupMember (4-byte payload) fail the same way.
Suggested fix
Check len(payload) against the minimum required size before every slice, and return an error. Because these functions currently return a single value, changing the signatures to return (T, error) would be a breaking change inside the SDK. Which approach would maintainers prefer: returning an error, or something else?
Notes
The Node.js SDK has the same class of problem (see #4968 and #4969). I searched open and closed issues and PRs for "Go SDK deserialize" and binary_response_deserializer and found nothing for the Go SDK.
Severity: Medium (unrecoverable panic in the client on malformed responses)
Affected area / component
Go SDK
Deployment
None
Versions
Commit SHA: 038f4714af47b5d56170518438f6d2e65f9a5c3f (origin/master, fork of apache/iggy) Server: 0.10.1-edge.1 Rust SDK (iggy): 0.12.1-edge.1 CLI (iggy-cli): 0.15.1-edge.1 Node.js SDK: 0.11.1-edge.1 Python SDK: 0.10.1.dev1 Java SDK: 0.10.1-SNAPSHOT C# SDK: 0.10.1-edge.1 Go SDK: github.com/apache/iggy/foreign/go
Hardware / environment
Environment: Local PC (Windows 11 Build 26300, x86_64) CPU / Memory: AMD / Intel multi-core host Storage: Local NVMe SSD (NTFS filesystem on drive D:) Runtime note: Windows native
Sample code
use iggy::client::{Client, MessageClient};
use iggy::clients::client::IggyClient;
use iggy::identifier::Identifier;
use iggy::messages::send_messages::{Message, Partitioning, SendMessages};
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box> {
let client = IggyClient::default();
client.connect().await?;
let stream_id = Identifier::numeric(1)?;
let topic_id = Identifier::numeric(1)?;
// Send loop
for i in 0..100 {
let payload = format!("Hello Iggy {i}").into_bytes();
let message = Message::from_payload(payload.into())?;
client
.send_messages(&SendMessages {
stream_id: stream_id.clone(),
topic_id: topic_id.clone(),
partitioning: Partitioning::partition_id(1),
messages: vec![message],
})
.await?;
}
Ok(())
}
Logs
panic: runtime error: slice bounds out of range [:4] [recovered]
panic: runtime error: slice bounds out of range [:4]
goroutine 6 [running]:
testing.tRunner.func1.2({0x846ec0, 0xc0000a6048})
C:/Program Files/Go/src/testing/testing.go:1790 +0x239
github.com/apache/iggy/foreign/go/binary_serialization.DeserializeLogInResponse({0xc0000a402e, 0x2, 0x2})
d:/IGGY/iggy/foreign/go/binary_serialization/binary_response_deserializer.go:193 +0x65
github.com/apache/iggy/foreign/go/binary_serialization.TestDeserializeLogInResponse_PanicOnTruncatedPayload(0xc0000a4000)
Iggy server config
N/A (Client-side deserialization issue; occurs on any server version or network condition where TCP response payload is truncated/malformed).
Reproduction
Add a test in foreign/go/binary_serialization/:
func TestDeserializeLogInResponse_Truncated(t *testing.T) {
_ = DeserializeLogInResponse([]byte{0x01, 0x02}) // needs 4 bytes
}
Run go test -run TestDeserializeLogInResponse_Truncated .
Contribution
- I'm willing to submit a pull request to fix this bug
Good first issue
- I think this could be a good first issue for a new contributor
- Ngôn ngữ chính
- Rust
- Star
- 5.3k
- Fork
- 548
- Merge trung bình
- 2 ngày 20 giờ
- Pull request đã merge (30 ngày)
- 194
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Có Dockerfile hoặc tệp Docker Compose
- 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 apache/iggy
-
go good first issue test
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 2 ngày
-
go good first issue test
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 2 ngày
-
go good first issue test
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 2 ngày
-
good first issue java test
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 2 ngày
-
good first issue javascript test
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 2 ngày
Issue tương tự
-
marketing
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
S: Untriaged T: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
libnyanpasu/clash-nyanpasu#6537 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 62/100
tauri-apps/tao#1445 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug P3
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 65/100
nearai/compose-manager#95 ·
Maintainer thường phản hồi trong vòng 1 ngày