AntFleet

Disagreement · 6017bf3f-anthropic-2

Token reassembly from `claude setup-token` can splice in non-token text and write garbage to CLAUDE_CODE_OAUTH_TOKEN

mismatch
repo 6f7fc663·PR #25·reviewed 1 week ago

Primary finding

Token reassembly from `claude setup-token` can splice in non-token text and write garbage to CLAUDE_CODE_OAUTH_TOKEN

highbughigh
  • dashboard/app/api/auth/route.ts:81-108
The first-line push is `tokenChars.push(trimmed)` without filtering — `trimmed` is the entire first line starting at `sk-ant-oat`, which in real `claude setup-token` output is wrapped inside an ANSI/box-drawing TUI and often contains trailing spaces, box characters, or ANSI escape sequences. Because no regex is applied to the first line, ANSI escape bytes and box-drawing glyphs get concatenated into `token`. The resulting `token` is then written to the GitHub secret as the OAuth token, silently corrupting auth. Worse, since `output.indexOf('sk-ant-oat')` only checks existence, even unrelated occurrences (e.g. inside a help string) get accepted. The handler then returns `ok: true` despite the bogus value.

Recommendation

Strip ANSI escapes first (e.g. `output.replace(/\x1b\[[0-9;]*[A-Za-z]/g, '')`), then extract with a strict regex like `/sk-ant-oat[A-Za-z0-9_-]+/` over the cleaned text, possibly joined across line breaks first by removing all whitespace inside the matched run. Validate length/format before calling `gh secret set` and surface an error otherwise.

Counterpart finding

Token extraction logic may capture non-token characters from first line

mediumbughigh
  • dashboard/app/api/auth/route.ts:84-86
  • dashboard/app/api/auth/route.ts:89-95
The code takes the entire first trimmed line starting at "sk-ant-oat" without restricting to allowed token characters. If the first line contains extra characters after the token (e.g., punctuation or guidance), they will be included in the secret, causing invalid storage/auth failures. The comment states stricter behavior than implemented, indicating a mismatch.

Recommendation

Extract the first-line token using a regex for contiguous valid chars, e.g., const m = tokenBlock.match(/^(sk-ant-oat[A-Za-z0-9_-]*)/); if (!m) error; const token = m[1] + continuationParts.join(''); Or apply the same /^[A-Za-z0-9_-]+$/ constraint to the first-line substring up to the first non-matching character.

Why this didn't post

This finding didn't meet AntFleet's unanimous agreement threshold. Both frontier models review every PR independently; only findings they both flag with the same severity and category are posted to the PR. This one fell through.

read the methodology →