Node SDK: deserializeConsumerGroup lacks payload bounds validation and throws unhandled ERR_BUFFER_OUT_OF_BOUNDS
Maintainers usually reply within 2 days
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
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
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:
- If
r.length < pos + 13(the fixed header size forid,partitionsCount,membersCount, andnameLength), reading integers throws an unhandled NodeRangeError [ERR_BUFFER_OUT_OF_BOUNDS]: "offset" is out of boundsinstead of throwingDeserializeError. - If
r.length < pos + 13 + nameLength,r.subarray(pos + 13, pos + 13 + nameLength)silently truncates the name bytes while returningbytesRead: 13 + nameLength. When called bydeserializePageinGET_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
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/iggy
-
go good first issue test
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 2 days
-
go good first issue test
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 2 days
-
go good first issue test
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 2 days
-
good first issue java test
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 2 days
-
good first issue javascript test
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 2 days
Similar issues
-
bug triaged tui ux wontfix
Difficulty 2/5 Half a day Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
bevyengine/bevy#26642 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day