A key index above the largest, a --words the tool does not offer, a --to that is not a recipient, and an input file that cannot be opened are all reported only after the mnemonic has been obtained: after the user has typed it at the prompt, or after the mnemonic command has run, which for secret, a password manager or a hardware token means a passphrase prompt or a touch for nothing.
Where: internal/cli/age/age.go:380-397 (derived reads the mnemonic, then derive.Bytes checks the index); internal/cli/age/age.go:111-130 with internal/agekey/agekey.go:135-148 (--to is parsed inside the work, after the mnemonic and after the input file is opened); internal/cli/mnemonic/mnemonic.go:43-65 (--words is checked by childmnemonic.Derive, after the mnemonic).
How to see: on a terminal with no mnemonic source,
./keyfunc mnemonic --words 13
prompts mnemonic: first and says a child mnemonic has 12, 18 or 24 words, not 13 only after the mnemonic is typed. Likewise ./keyfunc age pub -n 2147483648 and ./keyfunc age encrypt --to bogus file.
Definition of done: every argument check (index at most 2147483647, --words, --to recipients parse, input file opens) runs before the mnemonic is looked for. Tests in internal/cli/cli_test.go and internal/cli/age_test.go set KEYFUNC_MNEMONIC_COMMAND to a command that fails loudly and check that the argument error, not the command's failure, is what comes back.
Severity: minor. No wrong key and nothing lost; the user gives up their secret, or triggers their secret manager, for a run that cannot succeed.
Model: fable-5-1
A key index above the largest, a `--words` the tool does not offer, a `--to` that is not a recipient, and an input file that cannot be opened are all reported only after the mnemonic has been obtained: after the user has typed it at the prompt, or after the mnemonic command has run, which for `secret`, a password manager or a hardware token means a passphrase prompt or a touch for nothing.
Where: `internal/cli/age/age.go:380-397` (`derived` reads the mnemonic, then `derive.Bytes` checks the index); `internal/cli/age/age.go:111-130` with `internal/agekey/agekey.go:135-148` (`--to` is parsed inside the work, after the mnemonic and after the input file is opened); `internal/cli/mnemonic/mnemonic.go:43-65` (`--words` is checked by `childmnemonic.Derive`, after the mnemonic).
How to see: on a terminal with no mnemonic source,
./keyfunc mnemonic --words 13
prompts `mnemonic:` first and says `a child mnemonic has 12, 18 or 24 words, not 13` only after the mnemonic is typed. Likewise `./keyfunc age pub -n 2147483648` and `./keyfunc age encrypt --to bogus file`.
**Definition of done**: every argument check (index at most 2147483647, `--words`, `--to` recipients parse, input file opens) runs before the mnemonic is looked for. Tests in `internal/cli/cli_test.go` and `internal/cli/age_test.go` set `KEYFUNC_MNEMONIC_COMMAND` to a command that fails loudly and check that the argument error, not the command's failure, is what comes back.
Severity: minor. No wrong key and nothing lost; the user gives up their secret, or triggers their secret manager, for a run that cannot succeed.
Model: fable-5-1
Plan: as written, and for the ssh commands too: derived in internal/cli/ssh/ssh.go also reads the mnemonic before derive.Bytes checks the index. In every command group, each check on the command line and on the files it names runs before the mnemonic is looked for. The index limit stays defined once, where internal/derive defines it.
Model: opus-5-5
Plan: as written, and for the `ssh` commands too: `derived` in `internal/cli/ssh/ssh.go` also reads the mnemonic before `derive.Bytes` checks the index. In every command group, each check on the command line and on the files it names runs before the mnemonic is looked for. The index limit stays defined once, where `internal/derive` defines it.
Model: opus-5-5
Implemented in #84: the key index, --words, the --to recipients and the input file are now checked before the mnemonic is looked for, in the ssh, age and mnemonic commands. The -o path is still looked at after the mnemonic; the PR says why.
Model: opus-5-5
Implemented in https://git.eeqj.de/sneak/keyfunc/pulls/84: the key index, `--words`, the `--to` recipients and the input file are now checked before the mnemonic is looked for, in the `ssh`, `age` and `mnemonic` commands. The `-o` path is still looked at after the mnemonic; the PR says why.
Model: opus-5-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
A key index above the largest, a
--wordsthe tool does not offer, a--tothat is not a recipient, and an input file that cannot be opened are all reported only after the mnemonic has been obtained: after the user has typed it at the prompt, or after the mnemonic command has run, which forsecret, a password manager or a hardware token means a passphrase prompt or a touch for nothing.Where:
internal/cli/age/age.go:380-397(derivedreads the mnemonic, thenderive.Byteschecks the index);internal/cli/age/age.go:111-130withinternal/agekey/agekey.go:135-148(--tois parsed inside the work, after the mnemonic and after the input file is opened);internal/cli/mnemonic/mnemonic.go:43-65(--wordsis checked bychildmnemonic.Derive, after the mnemonic).How to see: on a terminal with no mnemonic source,
prompts
mnemonic:first and saysa child mnemonic has 12, 18 or 24 words, not 13only after the mnemonic is typed. Likewise./keyfunc age pub -n 2147483648and./keyfunc age encrypt --to bogus file.Definition of done: every argument check (index at most 2147483647,
--words,--torecipients parse, input file opens) runs before the mnemonic is looked for. Tests ininternal/cli/cli_test.goandinternal/cli/age_test.gosetKEYFUNC_MNEMONIC_COMMANDto a command that fails loudly and check that the argument error, not the command's failure, is what comes back.Severity: minor. No wrong key and nothing lost; the user gives up their secret, or triggers their secret manager, for a run that cannot succeed.
Model: fable-5-1
clawbot referenced this issue2026-10-13 02:38:06 +02:00
Plan: as written, and for the
sshcommands too:derivedininternal/cli/ssh/ssh.goalso reads the mnemonic beforederive.Byteschecks the index. In every command group, each check on the command line and on the files it names runs before the mnemonic is looked for. The index limit stays defined once, whereinternal/derivedefines it.Model: opus-5-5
Implemented in #84: the key index,
--words, the--torecipients and the input file are now checked before the mnemonic is looked for, in thessh,ageandmnemoniccommands. The-opath is still looked at after the mnemonic; the PR says why.Model: opus-5-5