fix(sdk): compute_auth_tag reads the owner secret from a file or stdin, never argv - #7699
Open
rmichelena wants to merge 1 commit into
Open
rmichelena wants to merge 1 commit into
rmichelena wants to merge 1 commit into
Conversation
…n, never argv The example that mints a NIP-OA auth tag took the owner's secret key as its first positional argument. Anything on argv is readable by every local user through /proc/<pid>/cmdline for the life of the process, and the documented invocation -- `-- $(cat owner.key) <pubkey>` -- also puts the secret through a shell expansion. The tag is computed on the owner's host, which is exactly where the owner key must not leak. The secret now arrives through `--owner-key-file <path>` or `--owner-key-stdin`; the agent pubkey stays positional; `--conditions` is a flag. The pre-change positional form is refused before anything else happens, and the refusal does not echo its arguments, so a script that still passes the secret on argv fails loudly instead of working. A bech32 nsec anywhere on argv is refused for the same reason (a 64-hex secret and a 64-hex x-only pubkey have the same shape, so the old form is caught by its argument count instead). No error message includes what was read. Tests (cargo test -p buzz-sdk --example compute_auth_tag): file and stdin forms produce a tag that verifies against the owner pubkey; the old form is refused without echoing the secret; missing source or pubkey; empty source. Nothing else in the repository invokes this example with the old form (grep of *.md, *.sh, *.py, *.ts, *.yml). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Roberto Michelena <77797875+rmichelena@users.noreply.github.com>
🔐 Codex Security Review
|
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
crates/buzz-sdk/examples/compute_auth_tag.rsmints the NIP-OA auth tag an agent needs, and it took the owner's secret key as a positional argument. Anything on argv is readable through/proc/<pid>/cmdlineby every local user for the life of the process, and the natural invocation (-- $(cat owner.key) <pubkey>) also routes the secret through a shell expansion. This runs on the owner's host — the one place the owner key must not leak.This PR makes the secret arrive only through
--owner-key-file <path>or--owner-key-stdin. The agent pubkey stays positional;--conditionsbecomes a flag.nsecanywhere on argv is refused for the same reason. (A 64-hex secret and a 64-hex x-only pubkey have the same shape, so the old hex form is caught by argument count rather than by sniffing.)Compatibility
Breaking for anyone invoking the example with the secret on argv — deliberately: that invocation is the leak. Nothing in the repository does (grep over
*.md,*.sh,*.py,*.ts,*.yml; thebenchmarks/.../test_keys.pycomment only cites this file for its fixture values). Same tag output as before for the same inputs.Test plan
cargo test -p buzz-sdk --example compute_auth_tag— 5 passed: file form and stdin form produce a tag that verifies against the owner pubkey; the old form is refused and the refusal does not echo the secret; missing source / missing pubkey; empty source.cargo fmt -p buzz-sdk -- --check,cargo clippy -p buzz-sdk --example compute_auth_tag -- -D warningsclean.3c7f288c; this is the same change rebased onmain@6dfd145cd.🤖 Generated with Claude Code