Skip to content

harden(auto-release): scope release token out of npm test#60

Merged
askalf merged 1 commit into
masterfrom
harden/auto-release-token-scope
Jul 11, 2026
Merged

harden(auto-release): scope release token out of npm test#60
askalf merged 1 commit into
masterfrom
harden/auto-release-token-scope

Conversation

@askalf

@askalf askalf commented Jul 11, 2026

Copy link
Copy Markdown
Owner

What

Harden auto-release.yml so the release token is never exposed to the test step.

Why

auto-release.yml was the only workflow whose checkout omitted persist-credentials: false. Because the job needs contents: write + actions: write to push the tag and dispatch publish.yml, the default checkout left that GITHUB_TOKEN in .git/config — and npm ci && npm test then ran with it sitting there. A compromised devDependency or test script could read .git/config and reuse the token to push to master or dispatch workflows.

This is a post-merge (trusted) context so severity is low, but it's a real blast-radius gap and it was inconsistent with the repo's own patterns:

  • publish.yml (the other release-path workflow) already runs persist-credentials: false + OIDC.
  • marketplace-watch.yml already pushes with an explicit in-URL token.

Change

  • checkout now sets persist-credentials: false.
  • The "Create annotated tag" step pushes with an explicit token URL (https://x-access-token:${GITHUB_TOKEN}@github.com/...), scoped to that step's env only, so the token never lives in .git/config during the install+test step.

gh release create and gh workflow run already use GH_TOKEN env (not git config), so they are unaffected. No behavior change to the release/publish flow.

The checkout persisted GITHUB_TOKEN (contents:write + actions:write) into
.git/config, where `npm ci && npm test` then ran with it available — a
compromised devDependency or test could read and reuse it. Set
persist-credentials: false and push the tag with an explicit in-URL token,
matching publish.yml's OIDC posture and marketplace-watch's push pattern.
@askalf
askalf merged commit 7b2cc32 into master Jul 11, 2026
8 checks passed
@askalf
askalf deleted the harden/auto-release-token-scope branch July 11, 2026 22:32
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.

1 participant