Skip to content

worker: report a wrong passphrase before an encrypted restore - #18

Draft
ash-iir wants to merge 1 commit into
mainfrom
fix-passphrase-probe
Draft

ash-iir wants to merge 1 commit into
mainfrom
fix-passphrase-probe

Conversation

@ash-iir

@ash-iir ash-iir commented Nov 19, 2026

Copy link
Copy Markdown
Owner

An encrypted app, special or path restore with a wrong passphrase got no clear error: on main the archive check passes an empty decrypt, and with #2 it becomes ERR_UNSAFE_ARCHIVE. The WebUI already re-asks for the passphrase on ERR_CRYPTO_PASS for all three (scripts.js), so the backend now reports that.

  • New age_pass_ok <file>: decrypts the first 256 KiB of the file through the existing dec_age and succeeds when any plaintext comes out. age checks the passphrase on the header and writes plaintext as it goes, so this is one scrypt KDF and no full decrypt.
  • App restore, special restore and path restore call it for .age archives before archive_safe, so before anything is wiped.
  • restore-test reports a wrong passphrase as pass:<archive> (was unsafe: or extract:).
  • The adb restore probe used a full dec_age of the whole archive; it now uses the helper.

Works alone on main and together with #2 (this check runs first). Small textual overlap with #2 and #16 around archive_safe calls.

Testing

  • sh -n, mksh -n, busybox sh -n; shellcheck -s sh: same 96 warnings as main.
  • Real age 1.2.1 + util-linux script, under mksh R59, busybox 1.37 ash and dash, using the real enc_age/dec_age/age_pass_ok: right passphrase (with \, quotes, -n) accepted for a 2 MB tar.zst.age and a tiny file; wrong, empty passphrase and missing file rejected; probe temp file removed. Also confirmed archive_safe on main still returns 0 for a wrong passphrase, which is why the probe runs first.
  • The module's bundled age build was not tested; the prefix behaviour relies on age writing plaintext before it hits the cut-off end of the file (true for 1.2.1).
  • Not tested on a rooted device.

Add age_pass_ok, which decrypts a short prefix of an age file (one
scrypt KDF, no full decrypt) to tell whether the passphrase opens it.
App, special and path restores run it before the archive check and the
wipe, so a wrong passphrase ends with ERR_CRYPTO_PASS and the WebUI asks
for the passphrase again. restore-test reports it as pass:<archive>.
The adb restore probe uses the same helper instead of a full decrypt.

Signed-off-by: ash-iir <254348575+ash-iir@users.noreply.github.com>
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.

1 participant