Open
Conversation
Extract validate_parent_hash_chain() as a standalone function that verifies consecutive blocks form a valid parent-hash chain. Called from both the realtime sync path (via SyncEngine::validate_parent_chain) and the gap-fill/backfill standalone worker (sync_range_standalone). Previously the backfill path skipped parent-hash checks entirely, allowing a malicious RPC to supply blocks with incorrect parent_hash linkage that would be written to the database without validation. Tests cover: valid chain, mismatch detection, single-block batches, empty input, and mid-batch mismatch detection. Amp-Thread-ID: https://ampcode.com/threads/T-019d458d-01b9-76ca-9fb1-c2b64d30877e Co-authored-by: Amp <amp@ampcode.com>
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.
Audit Finding Fix
Finding: Backfill-First Gap Worker Skips Parent-Hash Validation and Commits Forged Block Chains
The backfill/gap-fill standalone worker (
sync_range_standalone) did not validate parent hashes when ingesting blocks. A malicious RPC could supply blocks with incorrectparent_hashlinkage that would be written to the database without validation.Changes
validate_parent_hash_chain()as a standalone function that verifies consecutive blocks in a batch form a valid parent-hash chainsync_range_standalone()(gap-fill/backfill path) before writing to DBSyncEngine::validate_parent_chain()to reuse the same function for internal chain validationTests
5 unit tests covering: