Skip to content

feat(gha-audit): report permissions: write-all as write to every scope - #1124

Merged
sandstream merged 3 commits into
mainfrom
claude/web-kit-status-sync-p6fg9a-gha-write-all
Nov 27, 2026
Merged

sandstream merged 3 commits into
mainfrom
claude/web-kit-status-sync-p6fg9a-gha-write-all

Conversation

@sandstream

Copy link
Copy Markdown
Owner

What

permissions: write-all was reported only as its id-token: write part (src/gha-id-token.ts:62, grantsIdToken). On a job it was reported only when no step used an OIDC token. Contents, packages, actions and pull-request write were never named.

A new rule, src/gha-write-all.ts, wired into auditWorkflow, flags:

  • workflow-level permissions: write-all (<file>), where every job without its own permissions: gets it;
  • permissions: write-all on job <id> (<file>), for each job that sets it, bare or quoted.

Each row says that write-all grants write to every scope (contents, packages, actions, pull-requests, issues, deployments, pages, statuses, checks, security-events, discussions, attestations and id-token). It suggests a read-only GITHUB_TOKEN (permissions: contents: read or {}) as the default to aim for, with each write scope granted only on the job that needs it. It cites GitHub's guidance: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/controlling-permissions-for-github_token. Severity is medium and the rule is CWE-250, like the id-token rows.

The id-token rows stay as they are, so a workflow-level write-all now gives both rows. Changing to contents: read clears both.

A missing permissions: block is out of scope. I checked, and kit has no row for it: no gha rule, and nothing reads the repository or organisation default_workflow_permissions. The new rule does not flag it. The token then follows a default this file does not show, so a row would be a guess.

Before / after

Fixture: a workflow with permissions: write-all at the top, plus a release job that also sets it.

Before (main):

! workflow-level id-token: write (deploy.yml)  the top-level permissions grant id-token: write, …
! unused id-token: write on job release (deploy.yml)  job "release" grants id-token: write but no step uses an OIDC token …

After:

! workflow-level permissions: write-all (deploy.yml)  write-all grants write to every scope (contents, packages, actions, pull-requests, issues, deployments, pages, statuses, checks, security-events, discussions, attestations and id-token), so the GITHUB_TOKEN of every job without its own permissions block, and every action those jobs run, can push commits and tags, publish packages, edit pull requests and issues, and mint an OIDC token
    aim for a read-only GITHUB_TOKEN: set `permissions: contents: read` (or `{}`) at the top, and grant each write scope only on the job whose step needs it
! permissions: write-all on job release (deploy.yml)  job "release" sets write-all, which grants write to every scope (…)
! workflow-level id-token: write (deploy.yml)  …
! unused id-token: write on job release (deploy.yml)  …

src/gha-write-all.test.ts covers workflow and job level, quoted forms and an inline comment, both levels at once, and the shapes that must not flag (read-all, {}, a scoped block with write scopes, a commented-out line, no block). It also checks the row next to the id-token row through auditWorkflow. On main the test cannot load, because the module does not exist. The CLI output above is the behavioural before.

Docs

The kit gha-audit row in docs/COMMANDS.md now describes the rule and why a missing block is not reported. Comments in src/gha-audit.ts and src/gha-model-spend.ts now point at the new module. Fragment: changes/gha-write-all.md.

Scope notes

  • Harnesses: this is a static workflow-file rule and does not depend on the harness. It gives the same result whether kit runs from Claude Code, Codex or any other harness kit supports.
  • This PR and the static-cloud-keys PR both edit the same kit gha-audit line in docs/COMMANDS.md. Whichever merges second needs a rebase of that one line.
  • Tested on Linux, and Windows CI runs the tests. macOS is unverified. It is a pure text scan.

Found by kit-research#239 (docs/research/linkedin-batch-2026-11-27-vs-kit.md, GitHub hardening table: "write-all is reported only as its id-token: write part").


Generated by Claude Code

A workflow-level write-all was reported only as its id-token: write
part. gha-audit now flags write-all at workflow level and on each job
that sets it, names the scopes it grants, and suggests a read-only
GITHUB_TOKEN as the default to aim for. A workflow with no permissions
block is still not reported: kit has no row for it, and its token
follows a repository default the file does not show.

Found by kit-research#239.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

@sandstream-kit-reviewer sandstream-kit-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kit review gate at 5564ceea5fa8: not approved.

  • checks did not pass: windows shard 1/4, windows-native

@sandstream-kit-reviewer sandstream-kit-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kit review gate at 5564ceea5fa8: gates passed. All 33 checks passed on this commit, no file is in a protected class, 6 files and 165 lines changed. This approval is deterministic; it does not judge what the change is for.

…-sync-p6fg9a-gha-write-all

# Conflicts:
#	docs/COMMANDS.md
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

@sandstream-kit-reviewer sandstream-kit-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kit review gate at 6ac2593b5311: gates passed. All 33 checks passed on this commit, no file is in a protected class, 6 files and 165 lines changed. This approval is deterministic; it does not judge what the change is for.

@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

@sandstream
sandstream merged commit 17bbac4 into main Nov 27, 2026
33 checks passed
@sandstream
sandstream deleted the claude/web-kit-status-sync-p6fg9a-gha-write-all branch November 27, 2026 13:21
sandstream pushed a commit that referenced this pull request Nov 27, 2026
Keep both gha-audit rules: write-all (#1124) and static cloud keys.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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