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

Aperta Adatta ai principianti
#4,969 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@Mola-maker ci sta già lavorando.

Dal 18/11/2026.

  • #4973 di @Mola-maker — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
backend, databases

Direzione di ricerca

Leggi foreign/node/src/wire/consumer-group/group.utils.ts e confronta deserializeConsumerGroup con i controlli dei limiti in cluster.utils.ts e topic.utils.ts. Verifica come deserializePage usa il decoder in GET_GROUPS; il lavoro è completato quando intestazioni e nomi troncati generano DeserializeError con il contesto del gruppo di consumatori, invece di restituire dati parziali o generare un errore di intervallo del buffer.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Rust
Stelle
5.3k
Fork
548
Merge medio
2g 20h
PR unite (30g)
194

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/iggy

Tutte le issue di apache/iggy

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.