Repository navigation
wallet: detect cycles in BDB page traversal during migration - #34946
Closed
instagibbs wants to merge 1 commit into
Closed
instagibbs wants to merge 1 commit into
instagibbs wants to merge 1 commit into
Conversation
The read-only BDB parser follows page chains without tracking visited pages. A crafted BDB file with circular references causes an infinite loop with unbounded memory growth, crashing the process. Add visited-page sets to both the BTree DFS traversal and overflow page chain traversal, throwing on the first revisited page.
Contributor
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
sedited
added a commit
that referenced
this pull request
Jul 4, 2026
b2de59d wallet, bdbro: Validate btree page levels (Ava Chow) dc3a2b9 wallet, bdbro: Enforce overflow data lengths (Ava Chow) Pull request description: Alternative to #34946 BDB's overflow records include the total length of the data to be read from the overflow pages. If this length is impossible (larger than max page * page size), or if the data that we are reading exceeds the stated length, then throw an exception as this is an invalid BDB file. This prevents infinite looping if an overflow page makes a circular reference. BDB BTrees also include the level in the tree that the page is supposed to be at. Leaf pages are always at level 1. Starting from the root page, we can validate that each child has a level one less than the parent, until we reach a leaf page with a level of 1. This also ensures that we cannot have circular internal page references. ACKs for top commit: sedited: ACK b2de59d rkrux: code review ACK b2de59d Tree-SHA512: b740c349f68c78150ee57b77e8e81605bb45a7db4fbca3c3a0d87318178dfa197f37faf0cbfd8bef791ab20f4a9afc3d2571842960055a70b6c081d605f59f94
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.
The read-only BDB parser follows page chains without tracking visited pages. A crafted BDB file with circular references causes an infinite loop with unbounded memory growth, crashing the process.
Add visited-page sets to both the BTree DFS traversal and overflow page chain traversal, throwing on the first revisited page.
Script to craft a .dat file which demonstrated the issue (should run and suck up memory until OOM): https://gist.github.com/instagibbs/f92c17c34bfefa4aa391cb2b9c6306de
Issue discovered/demo'd/fixed by Claude.