DictionaryEncoder.decode accepts out-of-range dictionary indices
- Dominant language
- Java
- Stars
- 94
- Forks
- 152
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 11
Description
`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`.
Contributor guide
Research direction
Start at DictionaryEncoder.retrieveIndexVector and trace its use from DictionaryEncoder.decode, ListSubfieldEncoder.decodeListSubField, and StructSubfieldEncoder.decode. Verify that negative indices and indices equal to dictionaryCount are rejected before transfer.copyValueSafe; done means crafted dictionary indices cannot reach the dictionary copy with an invalid position.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- security
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100