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

Open Beginner friendly
#4,969 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@Mola-maker is already working on this.

Since Nov 18, 2026.

  • #4973 by @Mola-maker — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
node.js, typescript
Domain
backend, databases

Research direction

Read foreign/node/src/wire/consumer-group/group.utils.ts and compare deserializeConsumerGroup with the bounds checks in cluster.utils.ts and topic.utils.ts. Check how deserializePage uses the decoder in GET_GROUPS; done means truncated headers and names raise DeserializeError with the consumer group context instead of returning partial data or throwing a buffer range error.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Rust
Stars
5.3k
Forks
548
Avg merge
2d 20h
Merged PRs (30d)
194

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/iggy

All issues in apache/iggy

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.