Stop encouraging API key on argv for auth login#3
Merged
Conversation
Chris flagged that 'quartr auth login --api-key "$KEY"' leaks the key via shell history, ps, scrollback, and CI logs — anywhere argv is visible. This is especially bad for auth login, which is the exact moment we're committing the key to disk. Changes: - Drop the duplicate subcommand-local --api-key flag from auth login. It was always redundant with the global --api-key (which is stripped in extractGlobalFlags before subcommands ever see it), so removing it causes no behavior change for any reasonable invocation. - Add --api-key-stdin to auth login: reads one trimmed line from stdin. Standard pattern (gh, kubectl, op) for piping from a secret store. - Update Makefile install target to pipe via stdin instead of argv. - Update README and SKILL.md to recommend 'export QUARTR_API_KEY=...; quartr auth login' (uses env via the standard config precedence) or '... | quartr auth login --api-key-stdin' for piped input. The global --api-key flag is preserved for one-off commands where the trade-off is knowingly accepted (CI scripts, throwaway containers). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Chris flagged that
quartr auth login --api-key \"\$QUARTR_API_KEY\"leaks the key via shell history,ps, terminal scrollback, and CI logs — anywhere argv is visible. This is especially bad forauth loginbecause that's the exact moment we're committing the key to disk, so any leakage there compounds.Changes
--api-keyflag fromauth login. It was always redundant with the global--api-key(the global gets stripped inextractGlobalFlagsbefore subcommands see it), so removing it has no behavioral impact for any reasonable invocation.--api-key-stdintoauth login: reads one trimmed line from stdin. Standard pattern (gh auth login --with-token,kubectl --token,op signin) for piping a secret in from a secret store.printf '%s' \"\$QUARTR_API_KEY\" | quartr auth login --api-key-stdin).export QUARTR_API_KEY=...; quartr auth login(uses env via the standard config precedence) or... | quartr auth login --api-key-stdinfor piped input.The global
--api-key VALUEflag is preserved for one-off commands where the user knowingly accepts the argv leak (CI scripts, throwaway containers, ad-hoc queries) — removing it would be needlessly disruptive.What I considered and rejected
Chris's specific suggestion ("
--api-keyshould refer to a variable name to look up") would diverge fromkubectl/gh/aws/dockersemantics where--api-key/--tokenis always the literal value. Reusing one flag for two semantics would surprise people more than it helps. The fix above gets the security win without the UX divergence.Test plan
pre-commit run --all-filescleango test ./...cleanecho \$KEY | quartr auth login --api-key-stdinwrites the piped valueQUARTR_API_KEY=... quartr auth loginwrites the env valuequartr --api-key X auth loginwrites X (global flag still works)make installend-to-end withQUARTR_API_KEYexported persists correctly via the stdin path🤖 Generated with Claude Code