Back up wallet: appending .bak after Save can overwrite a different file without confirmation #1082

Open
opened 2026-11-08 23:57:44 +00:00 by jarolrod · 0 comments
jarolrod commented 2026-11-08 23:57:44 +00:00 (Migrated from github.com)

Back up wallet can replace an existing backup that was not selected in the Save dialog. The chooser checks the entered filename, but QML appends .bak after the dialog accepts it. An existing file at that rewritten destination is then overwritten without a replacement prompt.

Steps to reproduce with disposable wallets:

  1. Back up wallet B as archive.v1.bak.
  2. Make sure there is no file named archive.v1 in that directory.
  3. Open wallet A → Wallet settings → Back up wallet.
  4. In the Save dialog, select All files, enter archive.v1, and click Save.
  5. No overwrite confirmation appears. No file is created at archive.v1; instead, archive.v1.bak is replaced.

Restoring the resulting file confirmed that it contained wallet A rather than wallet B. Selecting the existing archive.v1.bak directly did show an overwrite prompt, and declining preserved the original file.

The final destination should be resolved before checking whether it exists and asking for overwrite confirmation. Adding a suffix must not bypass that decision.

The path change happens in WalletSectionPage.qml: resolvedBackupPath() appends the suffix, and the accepted handler passes that rewritten path to the backup operation.

Reproduced on qt6 at 6e54a48ab571, macOS / Qt 6.9, using the Qt Widgets fallback file chooser in an offscreen run. The native Cocoa chooser was not tested. The demonstrated loss was another wallet’s backup file; the original live wallet remained intact.

Back up wallet can replace an existing backup that was not selected in the Save dialog. The chooser checks the entered filename, but QML appends `.bak` after the dialog accepts it. An existing file at that rewritten destination is then overwritten without a replacement prompt. Steps to reproduce with disposable wallets: 1. Back up wallet B as `archive.v1.bak`. 2. Make sure there is no file named `archive.v1` in that directory. 3. Open wallet A → **Wallet settings → Back up wallet**. 4. In the Save dialog, select **All files**, enter `archive.v1`, and click **Save**. 5. No overwrite confirmation appears. No file is created at `archive.v1`; instead, `archive.v1.bak` is replaced. Restoring the resulting file confirmed that it contained wallet A rather than wallet B. Selecting the existing `archive.v1.bak` directly did show an overwrite prompt, and declining preserved the original file. The final destination should be resolved before checking whether it exists and asking for overwrite confirmation. Adding a suffix must not bypass that decision. The path change happens in [WalletSectionPage.qml](https://github.com/bitcoin-core/gui-qml/blob/6e54a48ab571cb46b813eb1d98a301401089192f/qml/pages/settings/WalletSectionPage.qml#L41): `resolvedBackupPath()` appends the suffix, and the accepted handler passes that rewritten path to the backup operation. Reproduced on `qt6` at `6e54a48ab571`, macOS / Qt 6.9, using the Qt Widgets fallback file chooser in an offscreen run. The native Cocoa chooser was not tested. The demonstrated loss was another wallet’s backup file; the original live wallet remained intact.
Sign in to join this conversation.
No description provided.