apache / apache/iceberg-python
Cython Avro decoder reads past the buffer end on malformed input
- 主要言語
- Python
- スター
- 1.1k
- フォーク
- 581
- 平均マージ
- 1日 17時間
- マージ済み PR(30日)
- 78
説明
Two places in `pyiceberg/avro/decoder_fast.pyx` advance the read pointer using a value taken from the stream, without bounding it against `self._end`.
**1. `read_bytes` does not validate the decoded length**
```python
cpdef inline bytes read_bytes(self):
cdef uint64_t length;
if self._current >= self._end: # only confirms 1 byte is available
raise EOFError(f"EOF: read 1 bytes")
decode_zigzag_ints(&self._current, 1, &length)
if length <= 0:
return b""
cdef const unsigned char *r = self._current
self._current += length # not checked against self._end
return r[0:length]
```
The guard confirms one byte is available before decoding the length, but the decoded `length` is then used to slice and to advance `_current` with no check that `_current + length <= _end`. A length field larger than the remaining buffer reads beyond it.
**2. `decode_zigzag_ints` has no end pointer to bound against**
```c
void decode_zigzag_ints(const unsigned char **buffer, const uint64_t count, uint64_t *result);
```
The signature takes a buffer and a count but no end, so the varint walk cannot stop at the buffer boundary — a run of bytes with the continuation bit set keeps advancing. It is called from five sites in the decoder (lines 93, 101, 111, 124, 176), including from `read_bytes` above.
Both are reachable from a malformed or hostile Avro manifest.
---
Issue investigation generated via claude, reviewed by Sung, Kevin, Fokko.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
pyiceberg/avro/decoder_fast.pyx から始め、read_bytes と decode_zigzag_ints、および issue に記載されている 5 つの呼び出し箇所を読みます。デコーダーを通して、形式が不正または切り詰められた Avro 入力を試します。形式が不正な入力がバッファーの末尾を越えて進めず、有効なデコードが既存のデコーダーの動作によって引き続きカバーされていれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- security
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 活発
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 72/100