Skip to content

Ask for the backup password again when it is wrong - #984

Merged
besendorf merged 1 commit into
mvt-project:mainfrom
arxhr007:feat/979-reprompt-backup-password
Oct 28, 2026
Merged

besendorf merged 1 commit into
mvt-project:mainfrom
arxhr007:feat/979-reprompt-backup-password

Conversation

@arxhr007

@arxhr007 arxhr007 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #979

When the backup password typed at the prompt was wrong, check-backup and check-androidqf ended with "Invalid backup password" (and check-androidqf skipped the backup modules), so an analyst with several candidate passwords had to run everything again for each one.

CmdAndroidCheckBackup.from_ab() now asks for the password again after a wrong one, up to three attempts in total (MAX_BACKUP_PASSWORD_ATTEMPTS). Each retry logs Invalid backup password, try again (attempt 2 of 3). After the last attempt it fails exactly as before: sys.exit(1) on its own, InvalidAndroidBackup when run as a sub-command. An empty answer on a retry ends the check with "No backup password provided", the same as an empty first answer.

A password given with --backup-password or in the environment is not asked for again. That keeps scripted runs and test_check_encrypted_backup_cli_invalid unchanged. Non-interactive runs still can't prompt, so they behave as before.

The shared "ask for a password, fail if there is none" step moved into _get_backup_password(); the rest of from_ab() is the same code in a loop.

Tests, in tests/test_check_android_backup.py:

  • a wrong password then the right one succeeds with two prompts
  • three wrong passwords exit 1 with three prompts and "Invalid backup password"
  • an empty answer on a retry exits 1 with "No backup password provided"
  • a wrong --backup-password still fails without prompting

The first three fail on main and pass here. I ran them with the related backup and androidqf test files, ruff check . and mypy on the changed module. The full suite has three failures in tests/test_cli_entry_points.py::test_main_completes_plugin_command_names; they fail the same way on an untouched main in my environment, so they are unrelated to this change.

A wrong password typed at the prompt ended the check with "Invalid backup
password", and check-androidqf skipped the backup modules. An analyst who
was handed several candidate passwords had to start the whole run again
for each one.

Ask for the password again, up to three attempts in total. A password
given with --backup-password or in the environment is not asked for
again, as before, so scripted runs fail the same way.

Fixes #979
@besendorf
besendorf merged commit df540d7 into mvt-project:main Oct 28, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

reprompt on backup decryption failure

2 participants