Skip to content

oauth-token.sh: don't tee the OAuth token to stderr - #421

Merged
max-sixty merged 1 commit into
mainfrom
oauth-token-redact
May 11, 2026
Merged

max-sixty merged 1 commit into
mainfrom
oauth-token-redact

Conversation

@max-sixty

@max-sixty max-sixty commented May 11, 2026 •

Copy link
Copy Markdown
Owner

oauth-token.sh runs claude setup-token under script(1) so the Ink TUI renders, then >&2 piped script(1)'s typescript copy to stderr so the user could watch the OAuth flow. When this wrapper is invoked from Claude Code's Bash tool, stderr is captured into the conversation transcript — leaking the freshly-minted long-lived sk-ant-oat01-… token in plain text.

script(1) already tees the typescript to $TMPFILE. Send its tee'd stdout to /dev/null instead of stderr. The token never reaches a captured stream; the existing grep-based extraction reads from $TMPFILE unchanged; the TOKEN=$(./oauth-token.sh) calling contract is identical.

Cost: the user no longer sees the live TUI on stderr. Mitigations: stderr still shows the "Running claude setup-token…" message, plus a hint pointing at $TMPFILE if the browser doesn't open and they need the OAuth URL. The extraction-failure path also stops dumping the raw file to stderr (a potential leak vector); it preserves the file on disk for inspection instead.

Test plan

  • bash -n syntax check passes
  • pre-commit run --all-files passes
  • End-to-end: ./oauth-token.sh 2>/tmp/stderr.log >/tmp/token; grep -c 'oat01-[A-Za-z0-9]' /tmp/stderr.log should print 0, and /tmp/token should contain a working ~108-char token.

This was written by Claude Code on behalf of @max-sixty

script(1) tees its typescript to both \$TMPFILE and its own stdout. The
previous code redirected that stdout to stderr so the user could watch
the OAuth flow — but when this wrapper runs under Claude Code's Bash
tool, stderr is captured into the conversation transcript, persisting
the freshly-minted long-lived sk-ant-oat01-… token in plain text.

Send script(1)'s stdout to /dev/null. The typescript still lands in
\$TMPFILE — that's the only copy — and the existing grep-based
extraction is unchanged. Point users at the file if their browser
doesn't open, and stop dumping the raw file to stderr on extraction
failure (preserve it for inspection instead).

Co-authored-by: Claude <[email protected]>
@max-sixty
max-sixty force-pushed the oauth-token-redact branch from 35823e3 to 36b1d74 Compare May 11, 2026 09:08
@max-sixty max-sixty changed the title oauth-token.sh: redact sk-ant-oat01 token from stderr passthrough oauth-token.sh: don't tee the OAuth token to stderr May 11, 2026
@max-sixty
max-sixty merged commit 4edd469 into main May 11, 2026
7 checks passed
@max-sixty
max-sixty deleted the oauth-token-redact branch May 11, 2026 09:16
@max-sixty max-sixty mentioned this pull request May 13, 2026
max-sixty added a commit that referenced this pull request May 13, 2026
Bumps generator to 0.0.18.

## Headline

Expose the `__TEND_DELETE__` sentinel so TOML overrides can reach RFC
7396 delete-key semantics — useful for dropping a generator-injected key
(e.g. `on.schedule` from a scheduled workflow) while keeping the rest.
Closes #439, thanks @jrdncstr for reporting.

## Other changes since 0.0.17

- fix(action): sum usage and num_turns across all result entries (#437)
- diag(action): upload execution-output.json (#408)
- fix(mention): run setup before PR checkout so stale PRs don't drop
mentions (#391)
- fix(running-in-ci): base skill worktree on default branch (#401)
- install-tend: fix oauth-token.sh returning an invalid token on macOS
(#398)
- oauth-token.sh: don't tee the OAuth token to stderr (#421)
- Skill hardening: bang-escape guidance, review-reviewers corruption
scans, dedup rules, $GITHUB_RUN_ID requirement

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants