apache / apache/arrow-java

DictionaryEncoder.decode accepts out-of-range dictionary indices

Aperta Adatta ai principianti
#1,261 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
94
Fork
152
Merge medio
3g 16h
PR unite (30g)
11

Descrizione

`DictionaryEncoder.retrieveIndexVector` guards each index from the index vector with `indexAsInt > dictionaryCount` before `transfer.copyValueSafe(indexAsInt, i)`. Valid indices are `0..dictionaryCount-1`, so the check is off by one: an index equal to `dictionaryCount` is accepted and reads one slot past the dictionary vector, and a negative index (a signed index type with the high bit set) is not rejected either and also reaches `copyValueSafe`. The index vector is decoded from an IPC/C-data payload, so a crafted dictionary-encoded batch yields an out-of-bounds read of the dictionary vector, exposing adjacent off-heap memory when bounds checking is disabled via `arrow.enable_unsafe_memory_access`.

The same helper backs `DictionaryEncoder.decode`, `ListSubfieldEncoder.decodeListSubField` and `StructSubfieldEncoder.decode`.

The bound should be `indexAsInt < 0 || indexAsInt >= dictionaryCount`.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Parti da DictionaryEncoder.retrieveIndexVector e segui il suo utilizzo da DictionaryEncoder.decode, ListSubfieldEncoder.decodeListSubField e StructSubfieldEncoder.decode. Verifica che gli indici negativi e gli indici uguali a dictionaryCount vengano rifiutati prima di transfer.copyValueSafe; il lavoro è completato quando indici del dizionario appositamente creati non possono raggiungere la copia del dizionario con una posizione non valida.

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

Valutazione

Stack tecnologico
java
Ambito
security
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Attiva
Chiarezza
Specificata chiaramente
Idoneità per principianti
74/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.