Skip to content

ci: codify the least scope of the release's cross-repo tokens; gate their use (#1602) - #1630

Merged
scttfrdmn merged 1 commit into
mainfrom
hardening/token-scope
Nov 14, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
hardening/token-scope

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #1602

GitHub won't show a secret's token type or scope, so this PR writes down the expected scope of each token, gates how the workflows use the tokens, and leaves the live comparison to you, as described below.

Added

  • infra/github-tokens/tokens.json sets the expected scope of the three cross-repo tokens the release holds. Each must be a fine-grained token on a single repository, never spore-host/spawn, with Contents: write and Metadata: read only:
Secret Target
HOMEBREW_TAP_GITHUB_TOKEN spore-host/homebrew-tap
SCOOP_BUCKET_GITHUB_TOKEN spore-host/scoop-bucket
DOCS_SYNC_TOKEN spore-host/spore-host; Contents: write is what POST /dispatches requires

Each entry also records the workflow step that reads it, why, and a proposed replacement.

  • github_tokens_test.go fails in five cases:

    • a workflow reads a secret, other than GITHUB_TOKEN, that isn't listed;
    • a listed token is a classic PAT, reaches spawn, reaches more than one repository, or holds any other permission;
    • a token is read outside the step env:/with: of its listed steps, which includes job- and workflow-level env:;
    • a listed step no longer reads its token;
    • a workflow that reads a token runs on a pull request.

    I watched it fail on a classic kind, spawn added to a token's repositories, a token in a job-level env:, and a token read by an unlisted step.

  • infra/github-tokens/README.md says what to compare live, and proposes the replacements.

  • docs/release-tap-token.md now asks for one token per tap, and says these are org secrets. It used to suggest a single token for both, and said the secrets were on spawn.

What you must verify live

  1. Open org Settings → Personal access tokens → Active tokens. Each secret's token must appear there with exactly the repository and permissions in the table. If a token isn't listed, it's classic, and a classic token fails the inventory. docs/release-tap-token.md says the tap tokens were re-set to a classic repo token after spawn#280, so expect to find one. If it's owned by a spawn admin, it would also bypass a tag ruleset.
  2. If you still have a token's value, curl -sI against the API: an x-oauth-scopes header means the token is classic.
  3. Org PAT policy: restrict classic PATs.
  4. Secret visibility, which I read today: all three are org secrets visible to 5 repos each (listed in the README).

Proposed replacements (not done here)

  • DOCS_SYNC_TOKEN: delete it, and have the umbrella's sync-cli-docs poll for new releases using its own GITHUB_TOKEN.
  • The tap tokens: replace them with a GitHub App installed only on the tap and the bucket, with short-lived tokens minted per run by actions/create-github-app-token. That would also have prevented the expiry in spawn#280.
  • GITHUB_TOKEN can't replace any of the three.

Checks

  • Root and internal/ tests pass under the hermetic wrapper.
  • golangci-lint and semgrep are clean.

@codecov

codecov Bot commented Nov 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn marked this pull request as ready for review November 14, 2026 20:22
@scttfrdmn
scttfrdmn force-pushed the hardening/token-scope branch from 3014972 to f744bff Compare November 14, 2026 20:22
@scttfrdmn
scttfrdmn force-pushed the hardening/token-scope branch from f744bff to 5f7fc5e Compare November 14, 2026 21:02
@scttfrdmn
scttfrdmn merged commit 250caaa into main Nov 14, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the hardening/token-scope branch November 14, 2026 21:19
@scttfrdmn scttfrdmn mentioned this pull request Nov 15, 2026
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.

security: Cross-repo PATs in release jobs can trigger workflows; their scope decides whether a leak reaches spawn's signing release

1 participant