AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Moderate 57 Bitcoin

wallet: check BDB last page LSN

Public commit record

What the developer wrote

Authored by Lőrinc

68/100 · Adequate
wallet: check BDB last page LSN

The BDB metadata field `last_page` stores the last valid page number, not the number of pages.
The read-only wallet migration parser currently checks reset LSNs with a half-open loop, so it skips the final page and may accept a database whose last page still depends on BDB log files.
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit fixes an off-by-one bug in Bitcoin Core's read-only wallet migration tool. The tool checks whether a Berkeley DB (BDB) wallet file is self-contained before migrating it. Due to a half-open loop, the tool was skipping the very last page of the database when verifying that all pages had their log sequence numbers (LSNs) reset. As a result, it could have accepted a wallet whose final page still depended on separate BDB log files, potentially leading to incomplete or inconsistent migration data. The fix changes the loop to include the last page.

Recommended action

Apply the patch. After applying, ensure any wallets previously migrated with the buggy code are considered for re-verification or re-migration, especially if migration occurred without BDB log files present. Users should be advised to migrate wallets only when associated BDB log files are available or to verify migrated wallet integrity.

Security signals we found

01

Off-by-one loop boundary in security-critical validation

02

Incomplete verification of database self-consistency before migration

03

Potential acceptance of database state dependent on external log files

04

Data integrity risk in wallet migration path

Risk score

Why this scored 57/100

Our methodology →
Potential impact 18/30
Exploitability 10/25
Stealth signal 8/15
Affected reach 10/15
Confidence 7/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.