Handle potential error from newBlockRangeBatcher #13344
Merged
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.
What type of PR is this?
What does this PR do? Why is it needed?
This is a really interesting bug that I'm surprised errcheck didn't identify. The error from
newBlockRangeBatcher
isn't checked. This could actually be exploited to crash Prysm with a nil pointer dereference.prysm/beacon-chain/sync/rpc_blob_sidecars_by_range.go
Lines 93 to 97 in 1123df7
Details
If an attacker sends a BlobSidecarsByRange request with the start slot greater than the current slot, it will return a
rangeParams
withsize: 0
.prysm/beacon-chain/sync/rpc_blob_sidecars_by_range.go
Lines 149 to 153 in 1123df7
When
newBlockRangeBatcher
gets this, it will returnnil, someErr
which doesn't get checked:prysm/beacon-chain/sync/block_batcher.go
Lines 45 to 47 in 45a2746
Then it will nil pointer dereference when
batcher.next()
is called:prysm/beacon-chain/sync/rpc_blob_sidecars_by_range.go
Lines 93 to 97 in 1123df7
This is not exploitable until the Deneb hardfork. The RPC handler is only registered at that epoch.
prysm/beacon-chain/sync/rpc.go
Lines 53 to 55 in 8aaab86