fix(storage): add bounds validation in Footer::Parse#2171
Conversation
…OOB read Validate that length >= 20 bytes (8B magic + 8B metadata_length + 4B checksum minimum) and that metadata_string_length does not exceed the available buffer before constructing the metadata string or copying the checksum. Without these checks, a corrupted or truncated serialized file could cause a heap out-of-bounds read. Also removes unused string_buffer allocation (dead code). Signed-off-by: 水芝 <fengjiangtian.fjt@alibaba-inc.com> Assisted-by: Claude:claude-opus-4-6
|
Hi maintainers, could you please add |
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🔴 Require kind labelWaiting for
This rule is failing.
🔴 Require version labelWaiting for
This rule is failing.
|
There was a problem hiding this comment.
Code Review
This pull request introduces safety checks in Footer::Parse within src/storage/serialization.cpp to prevent potential out-of-bounds memory accesses. Specifically, it ensures that the length is at least 20 bytes and that the metadata_string_length does not exceed the available buffer size. It also removes an unused string_buffer variable. There are no review comments, and I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Summary
Add bounds validation in
Footer::Parseto prevent heap out-of-bounds read on corrupted/truncated serialized index files.Fixes: #2170
Changes
length >= 20before reading inner fields (minimum overhead: 8B magic + 8B metadata_length + 4B checksum)metadata_string_length <= length - 20before constructing the metadata stringstring_bufferallocation (dead code)Test plan
make fmtclean🤖 Generated with Claude Code