Out-of-bounds read for corrupt view offsets in BaseVariableWidthViewVector
- Vorherrschende Sprache
- Java
- Sterne
- 94
- Forks
- 152
- Ø Merge
- 3 T. 16 Std.
- Gemergte PRs (30 T.)
- 11
Beschreibung
### Describe the bug
`ViewVarCharVector`/`ViewVarBinaryVector` store values longer than `INLINE_SIZE` (12 bytes) out of line, encoding a data-buffer index and an offset inline in the view buffer. When a vector is loaded from an IPC stream these fields come straight from the input.
`BaseVariableWidthViewVector` dereferences them verbatim in `getData`, `getDataPointer`, `hashCode`, `copyFromNotNull` and `splitAndTransferViewBufferAndDataBuffer`, e.g.
```java
dataBuffers.get(bufferIndex).getBytes(dataOffset, result, 0, dataLength);
```
Nothing checks that `bufferIndex` is in range or that `dataOffset + dataLength` fits inside the referenced data buffer. A crafted view whose offset/length points past the data buffer produces an out-of-bounds read: with the default bounds checking it throws `IndexOutOfBoundsException`, but with `arrow.enable_unsafe_memory_access=true` (commonly set in production) it reads arbitrary native heap into the returned value.
### Component(s)
Java
Beitragsleitfaden
Rechercherichtung
Beginne in BaseVariableWidthViewVector und untersuche die Out-of-line-View-Behandlung in getData, getDataPointer, hashCode, copyFromNotNull und splitAndTransferViewBufferAndDataBuffer. Vergleiche den verknüpften Pull Request und überprüfe anschließend, dass beschädigte Buffer-Indizes und Offset-/Length-Bereiche keine Lesezugriffe außerhalb der Grenzen mehr ermöglichen, auch wenn der unsafe memory access aktiviert ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java
- Bereich
- security
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 25/100