apache / apache/arrow-java

DictionaryEncoder.decode accepts out-of-range dictionary indices

未关闭 适合新手
#1,261 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Java
星标
94
派生
152
平均合并
3 天 16 小时
30 天内合并 PR
11

描述

`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`.

贡献指南

打开贡献指南

调研方向

从 DictionaryEncoder.retrieveIndexVector 开始,追踪其从 DictionaryEncoder.decode、ListSubfieldEncoder.decodeListSubField 和 StructSubfieldEncoder.decode 中的使用。验证负索引以及等于 dictionaryCount 的索引是否会在 transfer.copyValueSafe 之前被拒绝;完成标准是,构造的字典索引无法以无效位置到达字典副本。

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
security
Issue 类型
缺陷
难度
2/5
预计耗时
1-3 小时
活跃度
活跃
描述清晰度
描述清楚
新手友好度
74/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。