Problem
The file reader can use global buffer object (GBO) descriptor positions and sizes to construct read ranges before validating alignment and file bounds:
- The full metadata path computes file_len - schema_start and starts a tail read.
- The indexed metadata path computes position + size to construct ranges.
- Exact-version alignment validation occurs later in finish_metadata or finish_metadata_index.
This was surfaced while reviewing #8024. That series is intended to be a one-to-one refactor of the existing reader logic, so this issue tracks the hardening separately and should not block the refactor.
Impact
A malformed or untrusted Lance file can provide descriptors that:
- underflow or panic when a position is beyond the end of the file;
- wrap in release builds and produce an oversized range or allocation;
- trigger nearly whole-file reads when a small, misaligned schema position is supplied.
Expected behavior
Validate the exact-version GBO alignment and file bounds before descriptor-derived arithmetic or I/O. Malformed descriptors should return InvalidInputSource without starting an oversized read or allocation.
Acceptance criteria
- Validate descriptors immediately after decoding the GBO table in both full and indexed metadata paths.
- Use checked arithmetic for file_len - position and position + size.
- Reject positions outside the file and ranges that overflow.
- Add regression tests for unaligned, past-EOF, and overflowing descriptors in both paths.
- Preserve the stable file-format contract and valid-file behavior.
References
Problem
The file reader can use global buffer object (GBO) descriptor positions and sizes to construct read ranges before validating alignment and file bounds:
This was surfaced while reviewing #8024. That series is intended to be a one-to-one refactor of the existing reader logic, so this issue tracks the hardening separately and should not block the refactor.
Impact
A malformed or untrusted Lance file can provide descriptors that:
Expected behavior
Validate the exact-version GBO alignment and file bounds before descriptor-derived arithmetic or I/O. Malformed descriptors should return InvalidInputSource without starting an oversized read or allocation.
Acceptance criteria
References