Core: harden puffin reader to malformed input
- Dominant language
- Java
- Stars
- 9.2k
- Forks
- 3.5k
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 129
Description
### Feature Request / Improvement
Harden puffin reader/roaring bitmap parsing.
1. DeleteFile values aren't validated on all codepaths before reading.
2. Roaring bitmap structs are allocated in memory before the read, trusting the declaration in the file.
#2 is the big one; deserialization can be abused to allocate 2^31 bitmap structs, which would be disruptive on any multitenant process.
Claude review of production file reading
| Site | File | Role |
|---|---|---|
| Generic footer + blob read | `core/.../puffin/PuffinReader.java` | reads footer, seeks/allocates per blob |
| Zstd decompress | `core/.../puffin/PuffinFormat.java` | header-driven output allocation |
| DV read (query path) | `data/.../data/BaseDeleteLoader.java` `readDV` | guarded by `validateDV` |
| DV read (merge path) | `core/.../DVUtil.java` `readDV` | **not** guarded |
| DV blob envelope (len/magic/CRC) | `core/.../deletes/BitmapPositionDeleteIndex.java` | length prefix, magic, CRC, cardinality |
| Roaring bitmap deserialize | `core/.../deletes/RoaringPositionBitmap.java` | count/key-driven allocation |
| DV rewrite | `core/.../RewriteTablePathUtil.java` `rewriteDVFile` | only production caller of `PuffinReader.readAll` |
### Query engine
None
### Willingness to contribute
- [x] I can contribute this improvement/feature independently
- [ ] I would be willing to contribute this improvement/feature with guidance from the Iceberg community
- [ ] I cannot contribute this improvement/feature at this time
Contributor guide
Research direction
Start with core/.../deletes/RoaringPositionBitmap.java and core/.../DVUtil.java, then trace the read paths listed in the issue through PuffinReader.java, BitmapPositionDeleteIndex.java, and BaseDeleteLoader.java. Identify where declarations and DeleteFile values are consumed before validation. Done means malformed input cannot trigger oversized bitmap allocation and all listed read paths validate DeleteFile values before reading.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100