fix(avro): bound Cython decoder input - #3955
Open
akashchamp wants to merge 1 commit into
Open
Conversation
kevinjqliu
marked this pull request as draft
September 12, 2026 02:23
kevinjqliu
marked this pull request as ready for review
September 12, 2026 02:24
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No blocking issues remain.
Pull request overview
This PR hardens the Cython Avro decoder against malformed and truncated input while preserving valid decoding behavior.
Changes:
- Bounds varint decoding and preserves the cursor on incomplete input.
- Validates read, skip, and payload advances.
- Raises
EOFErrorfor malformed input and adds regression coverage.
File summaries
| File | Description |
|---|---|
tests/avro/test_decoder.py |
Adds malformed-input and negative-length coverage. |
pyiceberg/avro/decoder_fast.pyx |
Applies buffer bounds checks throughout decoding. |
pyiceberg/avro/decoder_basic.c |
Implements safe, bounded varint decoding. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3952.
Rationale for this change
The Cython Avro decoder advanced raw pointers using encoded lengths and continuation bytes without checking the end of its owned buffer. This change bounds every varint decode and payload/read/skip advance, preserves the cursor when a varint cannot be fully decoded, and reports malformed input as
EOFError. It also keeps Avro negative-length handling aligned with the pure Python decoder.Are these changes tested?
make linttests/avro/test_decoder.py— 68 passed.krb5-configand the optional nativekerberosextension.EOFErrorwithout advancing the cursor past valid input. A valid integer and bytes payload still decode successfully.Are there any user-facing changes?
Yes. Malformed input handled by the Cython Avro decoder now fails with
EOFErrorinstead of reading past the buffer. Valid input behavior is unchanged.