Node SDK: deserializeConsumerGroup lacks payload bounds validation and throws unhandled ERR_BUFFER_OUT_OF_BOUNDS

Đang mở Phù hợp với người mới
#4,969 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@Mola-maker đang làm issue này rồi.

Từ ngày 18/11/2026.

  • #4973 của @Mola-maker — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/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ệ
node.js, typescript
Lĩnh vực
backend, databases

Hướng nghiên cứu

Đọc foreign/node/src/wire/consumer-group/group.utils.ts và so sánh deserializeConsumerGroup với các kiểm tra giới hạn trong cluster.utils.ts và topic.utils.ts. Kiểm tra cách deserializePage sử dụng bộ giải mã trong GET_GROUPS; hoàn thành khi các header và tên bị cắt ngắn gây ra DeserializeError kèm ngữ cảnh nhóm consumer, thay vì trả về dữ liệu một phần hoặc ném lỗi phạm vi buffer.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug javascript sdk
Description

In foreign/node/src/wire/consumer-group/group.utils.ts, deserializeConsumerGroup is defined as:

export const deserializeConsumerGroup = (r: Buffer, pos = 0): ConsumerGroupDeserialized => {
  const id = r.readUInt32LE(pos);
  const partitionsCount = r.readUInt32LE(pos + 4);
  const membersCount = r.readUInt32LE(pos + 8);
  const nameLength = r.readUInt8(pos + 12);
  const name = r.subarray(pos + 13, pos + 13 + nameLength).toString();

  return {
    bytesRead: 4 + 4 + 4 + 1 + nameLength,
    data: {
      id,
      name,
      partitionsCount,
      membersCount,
    }
  }
};

Unlike other wire decoders in the Node SDK (such as cluster.utils.ts and topic.utils.ts), deserializeConsumerGroup performs zero bounds validation on the buffer r or the starting offset pos:

  1. If r.length < pos + 13 (the fixed header size for id, partitionsCount, membersCount, and nameLength), reading integers throws an unhandled Node RangeError [ERR_BUFFER_OUT_OF_BOUNDS]: "offset" is out of bounds instead of throwing DeserializeError.
  2. If r.length < pos + 13 + nameLength, r.subarray(pos + 13, pos + 13 + nameLength) silently truncates the name bytes while returning bytesRead: 13 + nameLength. When called by deserializePage in GET_GROUPS, this desynchronizes subsequent item decoders or reads past the end.
Steps to reproduce
import { deserializeConsumerGroup } from './group.utils.js';

// Truncated buffer smaller than the 13-byte header
const truncated = Buffer.alloc(8);
deserializeConsumerGroup(truncated); // RangeError [ERR_BUFFER_OUT_OF_BOUNDS]
Proposed fix

Validate that r.length >= pos + 13 and r.length >= pos + 13 + nameLength and call deserializeError('consumer group', pos, r.length, ...) when insufficient.

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

Mở trong Codespaces

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.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/iggy

Tất cả issue của apache/iggy

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.