A wrong passphrase gives an error that says so #171

Merged
clawbot merged 1 commits from fix/157-wrong-passphrase-error into next 2026-10-14 23:48:51 +02:00
Collaborator

Fixes #157.

A passphrase that does not decrypt the passphrase unlocker, from SB_UNLOCK_PASSPHRASE or typed at the prompt, used to fail with age's "no identity matched any of the recipients" and advice to give the vault a new unlocker from its mnemonic, which would replace an unlocker that works. Every command that opens the vault now ends its error with "wrong passphrase for unlocker" and the unlocker's ID, with no mnemonic advice, and exits 1.

  • PassphraseUnlocker.GetIdentity turns age's no-match error into one that wraps the new secret.ErrWrongPassphrase. Both ways of giving the passphrase reach this code.
  • withMnemonicAdvice leaves that error alone, as it already does when no passphrase was read.
  • TestWrongPassphraseNamesMnemonic, which pinned the old message, became TestWrongPassphraseNamesPassphrase: it checks the sentinel with errors.Is and that the advice is absent, then opens the vault with the right passphrase. The new TestDamagedUnlockerNamesMnemonic checks that a priv.age that is not an age file keeps the advice. TestAddSecretForceWithWrongPassphraseChangesNothing checks the sentinel instead of age's error, which is no longer in the chain.

README.md does not describe this error, so it is unchanged.

Judgement call: age cannot tell a wrong passphrase from a damaged key inside a priv.age whose header reads, so that case now reads as a wrong passphrase.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/secret/issues/157. A passphrase that does not decrypt the passphrase unlocker, from `SB_UNLOCK_PASSPHRASE` or typed at the prompt, used to fail with age's "no identity matched any of the recipients" and advice to give the vault a new unlocker from its mnemonic, which would replace an unlocker that works. Every command that opens the vault now ends its error with "wrong passphrase for unlocker" and the unlocker's ID, with no mnemonic advice, and exits 1. - `PassphraseUnlocker.GetIdentity` turns age's no-match error into one that wraps the new `secret.ErrWrongPassphrase`. Both ways of giving the passphrase reach this code. - `withMnemonicAdvice` leaves that error alone, as it already does when no passphrase was read. - `TestWrongPassphraseNamesMnemonic`, which pinned the old message, became `TestWrongPassphraseNamesPassphrase`: it checks the sentinel with `errors.Is` and that the advice is absent, then opens the vault with the right passphrase. The new `TestDamagedUnlockerNamesMnemonic` checks that a `priv.age` that is not an age file keeps the advice. `TestAddSecretForceWithWrongPassphraseChangesNothing` checks the sentinel instead of age's error, which is no longer in the chain. `README.md` does not describe this error, so it is unchanged. Judgement call: age cannot tell a wrong passphrase from a damaged key inside a `priv.age` whose header reads, so that case now reads as a wrong passphrase. Model: opus-5-5
clawbot added the needs-review label 2026-10-14 22:29:25 +02:00
clawbot self-assigned this 2026-10-14 22:29:25 +02:00
clawbot force-pushed fix/157-wrong-passphrase-error from ef61db976c to 24e74e5f61 2026-10-14 22:33:01 +02:00 Compare
clawbot added 1 commit 2026-10-14 23:24:05 +02:00
A passphrase that did not decrypt the passphrase unlocker failed with age's
"no identity matched any of the recipients" and advice to give the vault a
new unlocker from its mnemonic, which would replace an unlocker that works.
GetIdentity now turns that age error into "wrong passphrase for unlocker
<id>", wrapping the new secret.ErrWrongPassphrase, and withMnemonicAdvice
leaves it alone, as it does when no passphrase was read. A passphrase from
SB_UNLOCK_PASSPHRASE and a typed one both reach this code. A priv.age that
is not an age file keeps the advice.

Judgement call: age cannot tell a wrong passphrase from a damaged key inside
a priv.age whose header reads, so that case now reads as a wrong passphrase.

Model: opus-5-5
clawbot force-pushed fix/157-wrong-passphrase-error from 24e74e5f61 to 655a112e74 2026-10-14 23:24:05 +02:00 Compare
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit 72cd6c30a1 into next 2026-10-14 23:48:51 +02:00
clawbot deleted branch fix/157-wrong-passphrase-error 2026-10-14 23:48:51 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/secret#171