Skip to content

fix(cli): send GitHub PAT in POST body, not the URL query string - #159

Merged
tim-thacker-nullify merged 1 commit into
mainfrom
fix/github-token-post
Jun 19, 2026
Merged

tim-thacker-nullify merged 1 commit into
mainfrom
fix/github-token-post

Conversation

@tim-thacker-nullify

Copy link
Copy Markdown
Member

Claude

Why

The GitHub-Actions token exchange (internal/lib/get_token.go) sent the GitHub PAT in the URL query string (/auth/github_token?token=…), where it leaks into access logs, proxies, and request-logging middleware. The code carried a standing TODO(security).

What

Send {owner, token} as a JSON POST body to /auth/github_token with Content-Type: application/json. No other behavior changes.

Rollout ordering ⚠️

This is the client half of a coordinated change. The backend POST support is nullify monorepo PR #5485 (feat(auth): accept GitHub token via POST body). That must merge and deploy before this CLI change ships, otherwise the CLI would POST to a GET-only endpoint. Both are drafts until then; the backend keeps GET for already-released CLIs.

Test plan

  • go build ./..., go vet ./internal/lib/..., go test ./internal/lib/... pass.

🤖 Generated with Claude Code

GetNullifyToken exchanged the GitHub PAT for a Nullify token via
GET /auth/github_token?token=…, putting the secret in the URL where it leaks
into access logs and proxies. Send {owner, token} as a JSON POST body instead.

Requires the backend POST support (nullify monorepo auth/ PR #5485) to be
deployed first; the backend keeps GET for older CLIs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tim-thacker-nullify tim-thacker-nullify added the patch Patch version updates (fixes) label May 26, 2026
@tim-thacker-nullify

Copy link
Copy Markdown
Member Author

Claude

Status check (2026-05-28): still relevant, still blocked.

CLI side: internal/lib/get_token.go:64 still has the TODO(security) and still POSTs the PAT in the URL query string — nothing on main has changed.

Backend side: monorepo PR #5485 (feat(auth): accept GitHub token via POST body) is still in draft (last updated 2026-05-26; require-labels failing, Detect Changes skipped). Until that merges and deploys, the CLI half here would POST to a GET-only endpoint.

Recommend: leave in draft, ping when #5485 is merged and rolled out.

@tim-thacker-nullify
tim-thacker-nullify marked this pull request as ready for review June 19, 2026 06:35
@tim-thacker-nullify
tim-thacker-nullify merged commit 31471af into main Jun 19, 2026
4 checks passed
@tim-thacker-nullify
tim-thacker-nullify deleted the fix/github-token-post branch June 19, 2026 06:35
scrut-nick pushed a commit to scrut-nick/nullify-cli that referenced this pull request Aug 28, 2026
Our transport had no 401 handling at all. It refreshed on a five-minute TTL
and, when the provider failed, fell back to the stale cached token - so against
a credential revoked mid-life every single request failed, forever, with no
attempt to fetch a replacement. That is the shape of the outage we just spent
a week diagnosing.

This ports the behaviour of upstream Nullify-Platform#165 onto our simpler transport rather
than adopting the file wholesale, because this fork branched at Nullify-Platform#138 and the
upstream version depends on Nullify-Platform#151/Nullify-Platform#158 that we do not carry.

  - refreshProvider is a second, distinct provider used only after a 401.
    tokenProvider returns the stored token untouched while it still looks
    valid, so reusing it for the retry would replay the rejected string - the
    exact bug Nullify-Platform#165 was written to fix.
  - auth.ForceRefreshToken refreshes regardless of the recorded expiry, and
    reports ErrNotRefreshable when the credentials carry no refresh token.
  - lib.RefreshNullifyToken reports client.ErrTokenNotRefreshable for sources
    that yield a fixed string (--nullify-token, NULLIFY_TOKEN), so the
    transport surfaces the 401 instead of retrying something that cannot change.
  - Separate backoff clocks for the TTL and 401 paths: one provider failing
    says nothing about the other, and without them a rejected credential puts
    a blocking refresh in front of every request.
  - A refresh that returns nothing, or returns the token just rejected, leaves
    the cache alone rather than overwriting a working value with junk.
  - Request bodies are buffered so a retried POST carries its payload.

Tested: retry-and-succeed, fixed-source surfaces the 401, same-token and empty
returns do not loop or clobber the cache, body replay, backoff suppression,
concurrent rotation, non-401 passthrough, and provider-failure backoff.
Upstream's own note on Nullify-Platform#165 was that this code went broken from February to
August precisely because it had no tests.

CLAUDE.md records what remains unported, including Nullify-Platform#159 - the GitHub PAT is
still sent in a URL query string.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mcq6LfAVPzKZL5rpvww13R
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Patch version updates (fixes)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant