buzz
buzz copied to clipboard
feat(cli): add --private-key-file flag, warn on argv key exposure
Problem
Several buzz subcommands accept the identity secret directly on the command line:
buzz channels remove-member --relay <url> --private-key <nsec> \
--channel <uuid> --pubkey <hex>
Two consequences:
- Shell history. The full
nsec1...is written verbatim to~/.zsh_historyand every per-session file in~/.zsh_sessions/. These are plaintext, included in Time Machine backups, and readable by any process running as that user. - Process listing. While the command runs, the key is visible in
ps auxto any local user.
Once it has happened, cleanup is unreliable — key rotation is the only practical remedy.
Closes #4032.
Related: #2883 (keeping BUZZ_PRIVATE_KEY out of agent-controlled processes) and #3629 (key rendered in --help output, fixed).
Fix
Add a **--private-key-file flag:
- Reads the hex-or-nsec key from a file at startup
- The key never appears in shell history or process listings
- Mutually exclusive with
--private-key/BUZZ_PRIVATE_KEY(clear error if both provided) - Recommended file mode 0600
When --private-key is used as a direct argv value (not from the env var), emit a stderr warning pointing the user at the safer alternatives:
warning: --private-key exposes your key in shell history and process listings;
Testing
buzz-cli lib test suite: 271 passed, 0 failed.