Fix integer overflow OOB reads in Block::DecodeEntry and ReadBlock - #1353
Open
smoke-wolf wants to merge 1 commit into
Open
smoke-wolf wants to merge 1 commit into
smoke-wolf wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
smoke-wolf
force-pushed
the
fix-block-readblock-oob
branch
from
September 2, 2026 08:09
686c38f to
2041ddb
Compare
DecodeEntry: the bounds check (limit - p) < (non_shared + value_length) used uint32_t addition which wraps on overflow, allowing a crafted block entry to bypass the check and cause an out-of-bounds read in ParseNextKey. Fix by checking each field sequentially against the remaining space. ReadBlock: n + kBlockTrailerSize can overflow size_t when handle.size() is near SIZE_MAX, causing an undersized allocation followed by an OOB read at data[n]. Fix by rejecting unreasonable block sizes and checking for arithmetic overflow before allocation. Both bugs are reachable via crafted SST files and confirmed under AddressSanitizer.
smoke-wolf
force-pushed
the
fix-block-readblock-oob
branch
from
September 2, 2026 08:12
2041ddb to
be43045
Compare
Author
|
Discovered by Maliq Barnard. ASAN-confirmed integer overflow → heap-buffer-overflow in Block::DecodeEntry (uint32 wrap) and ReadBlock (size_t wrap) via crafted SST files. |
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.
Summary
Two integer overflow bugs in the SST table reader allow crafted SST files to trigger heap-buffer-overflow reads. Both confirmed under AddressSanitizer.
Bug 1: uint32 overflow in
DecodeEntry(table/block.cc:71)The bounds check
static_cast<uint32_t>(limit - p) < (*non_shared + *value_length)wraps whennon_shared + value_lengthexceeds 2^32. A crafted entry withnon_shared=50, value_length=0xFFFFFFD0wraps the sum to 2, bypasses the check, thenkey_.append(p, 50)reads 50 bytes from a buffer with only 5 remaining.Fix: Check each field sequentially against remaining space instead of summing.
Bug 2:
size_toverflow inReadBlock(table/format.cc:78)new char[n + kBlockTrailerSize]wraps whenhandle.size()is near SIZE_MAX, allocating a tiny buffer. Thendata[n]at line 102 reads at offset ~SIZE_MAX.Fix: Cap block size at 64MB and check for arithmetic overflow before allocation.
🤖 Generated with Claude Code