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

wallet: RestoreWallet failure, erase only what was created

Public commit record

What the developer wrote

Authored by furszy

73/100 · Adequate
wallet: RestoreWallet failure, erase only what was created

Track what RestoreWallet creates so only those files and directories
are removed during a failure and nothing else. Preexisting paths
must be left untouched.

Note:
Using fs::remove_all() instead of fs::remove() in RestoreWallet does
not cause any problems currently, but the change is necessary for the
next commit which extends RestoreWallet to work with existing directories,
which may contain files that must not be deleted.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This change fixes a cleanup bug in Bitcoin Core's wallet restore feature. Previously, if restoring a wallet failed part-way through, the code would delete the entire wallet directory using a broad 'remove everything' command. The patch makes the function remember exactly which files and folders it created, and only delete those specific items on failure. Right now this doesn't cause data loss, but it is needed to safely support a follow-up change where restore may reuse an existing directory that could contain other important files.

Recommended action

Treat as a hardening/defensive fix with no immediate exploitable vulnerability. Review the follow-up commit that allows restoring into existing directories to ensure the new flags fully cover all created paths. Continue normal testing of wallet restore failure paths.

Security signals we found

01

Data-loss prevention: replaces broad fs::remove_all with targeted removal of only restore-created paths

02

State tracking: adds flags to record which filesystem mutations the function performed

03

Defensive cleanup: uses Assume(fs::is_empty(wallet_path)) before directory removal

04

Preparation for future feature that will allow restoring into existing directories

Risk score

Why this scored 34/100

Our methodology →
Potential impact 8/30
Exploitability 5/25
Stealth signal 4/15
Affected reach 6/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.