bugfix: exiting custom backup password text form causes yikes
What changed, and why it matters
This commit fixes a bug in the COLDCARD hardware wallet where cancelling out of the 'Custom Backup Password' text-entry screen during a backup restore would cause a crash (internally called a 'yikes'). The fix adds a simple check so that if the user exits without entering a password, the restore process stops gracefully instead of continuing with an empty value and crashing.
Treat as a low-severity reliability bug. Review the guard condition: 'if not pwd: return' appears to check the wrong variable and may not fully protect against the empty ipw case; consider changing it to 'if not ipw: return'. Ensure the regression test covers both temporary and permanent seed restore paths. No immediate security response is indicated unless crashes can be chained into further behavior.
Security signals we found
Unhandled exception/crash in security-critical restore flow
User-triggered abort path not validated before continuing
Potential denial-of-service against local restore operation
Evidence from the diff
In shared/backups.py, inside restore_complete(), when restoring a backup with words=False, the code calls ux_input_text() to collect a backup password and appends the result to pwd. If the user cancels the text input, ux_input_text() returns None/empty, and the subsequent pwd.append(ipw) followed by done(pwd) apparently triggered an unhandled exception (‘yikes’). The patch inserts ‘if not pwd: return’ immediately after the input, but this check is suspicious because pwd is a list that was initialized earlier and would not normally be falsy just because ipw is empty; the intended guard likely should check ipw. Regardless, the change prevents the crash path by returning early when the password input is aborted. A regression test is added in testing/test_backup.py that simulates cancelling the password input twice during a developer-mode restore.
Changed components
shared/backups.py:restore_complete()COLDCARD backup restore UI flowCustom Backup Password input handlingInspect captured patch +29 / −0
diff --git a/releases/Next-ChangeLog.md b/releases/Next-ChangeLog.md
index 0a33181..a40e077 100644
--- a/releases/Next-ChangeLog.md
+++ b/releases/Next-ChangeLog.md
@@ -4,6 +4,7 @@ This lists the new changes that have not yet been published in a normal release.
# Shared Improvements - Both Mk4 and Q
+- Bugfix: Exiting text input of Custom Backup Password causes yikes
# Mk4 Specific Changes
diff --git a/shared/backups.py b/shared/backups.py
index 34d8fae..d7e5a1a 100644
--- a/shared/backups.py
+++ b/shared/backups.py
@@ -588,6 +588,7 @@ async def restore_complete(fname_or_fd, temporary=False, words=True, usb=False):
if words is False:
ipw = await ux_input_text("", prompt="Your Backup Password",
min_len=bkpw_min_len, max_len=128)
+ if not pwd: return
pwd.append(ipw)
await done(pwd)
diff --git a/testing/test_backup.py b/testing/test_backup.py
index 9e2e15a..3a126ee 100644
--- a/testing/test_backup.py
+++ b/testing/test_backup.py
@@ -717,4 +717,31 @@ def test_restore_usb_backup(backup_system, set_seed_words, cap_story, verify_eph
_, story = cap_story()
assert "now reboot" in story
+@pytest.mark.parametrize('tmp', [True, False])
+def test_exit_dev_backup(tmp, unit_test, goto_home, pick_menu_item, need_keypress, src_root_dir,
+ microsd_path, press_cancel, cap_menu, cap_story):
+ fname = 'backup.7z'
+ fn = microsd_path(fname)
+ shutil.copy(f'{src_root_dir}/docs/backup.7z', fn)
+
+ if not tmp:
+ unit_test('devtest/clear_seed.py')
+
+ goto_home()
+ pick_menu_item('Advanced/Tools')
+ if tmp:
+ pick_menu_item("Danger Zone")
+ pick_menu_item('I Am Developer.')
+ pick_menu_item('Restore Bkup')
+
+ time.sleep(.1)
+ pick_menu_item(fname)
+
+ # do not write anything just exit
+ # yikes
+ press_cancel()
+ time.sleep(.2)
+ pick_menu_item("Restore Bkup")
+ press_cancel()
+
# EOF
Why this scored 31/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.