Skip to content

ci: keep the release-notes write token away from PR-supplied code - #435

Merged
chaitanyapotti merged 2 commits into
masterfrom
ci/release-notes-token-isolation
Dec 3, 2026
Merged

chaitanyapotti merged 2 commits into
masterfrom
ci/release-notes-token-isolation

Conversation

@hieu-w

@hieu-w hieu-w commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Motivation and Context

The release-notes job grants contents: write. Its checkout already set persist-credentials: false, but the Check release notes step still carried GH_TOKEN in its environment while running PR-lockfile-provided binaries — the same exposure Cursor Bugbot flagged in torusresearch/loglevel-sentry#52 and fixed in torusresearch/loglevel-sentry#63:

  • the step ran npm exec -- changeset status and node (binaries installed from the PR's lockfile) with GH_TOKEN in its environment, so a hijacked dependency in a PR lockfile could read the job's write token and push anywhere in the repository, bypassing the read-only token GitHub normally enforces for Dependabot workflows.

Jira Link

Description

Ports the step-split half of torusresearch/loglevel-sentry#63:

  • The Check release notes step (id: changeset) now runs every lockfile-provided binary (npm ci, npm exec, node) without any token in its environment. The existing waive/auto-create/fail logic is kept verbatim, and when the changeset must be auto-created the step exports the file path and its base64 content via step outputs.
  • A new Commit changeset step holds GH_TOKEN and runs nothing from node_modules — only gh and shell — performing the same Contents-API GET/PUT as before (re-run safe via the existing sha lookup).
  • Job id, check name (release-notes), and all three outcomes (waive dev-deps, auto-create patch changeset for chore(deps), fail human PRs without a changeset) are unchanged.
Before After
Write token during npm exec/node In untrusted step env (GH_TOKEN) Not present
Contents-API commit Same untrusted step Separate token-holding step, gh + shell only

Note

Medium Risk
Touches a job with contents: write and Dependabot auto-changeset behavior; a mistake in the step split could break commits or still leak the token.

Overview
Hardens the release-notes job so the contents: write token is never exposed to code from the PR lockfile.

The Check release notes step (id: changeset) no longer sets GH_TOKEN. It still runs waive/auto-create/fail logic via npm ci, npm exec, and node, and when it auto-creates a Dependabot patch changeset it writes path and base64 b64 to step outputs instead of calling the Contents API inline.

A new Commit changeset step runs only when those outputs are set, sets GH_TOKEN, and uses gh plus shell to perform the same GET/PUT Contents-API commit (including re-run-safe sha handling). Comments document which steps are trusted vs untrusted.

Reviewed by Cursor Bugbot for commit 879c050. Configure here.

Co-authored-by: Cursor <cursoragent@cursor.com>
@hieu-w
hieu-w requested a review from a team as a code owner December 2, 2026 13:27

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 879c050. Configure here.

Comment thread .github/workflows/ci.yml Resolved
Step-level token isolation (PR #435) does not hold within one job: the
untrusted step runs lockfile-provided binaries (npm ci install scripts,
npm exec, node) that inherit GITHUB_OUTPUT and can rewrite
GITHUB_PATH/GITHUB_ENV, so a hijacked dependency could forge the
path/b64 outputs or capture the write token via the trusted step's gh
execution and push arbitrary files.

Split the release-notes job instead:
- release-notes (untrusted, contents: read) runs npm ci / npm exec / node,
  then uploads the changeset via artifact and exports only a boolean flag.
- release-notes-commit (trusted, contents: write) runs on a fresh runner,
  so PATH/ENV tampering from the untrusted job is gone. It recomputes the
  commit path from PR context and PUTs the downloaded artifact with gh.

Addresses Bugbot finding 01d7c393 on PR #435.

Co-authored-by: Cursor <cursoragent@cursor.com>
@chaitanyapotti
chaitanyapotti merged commit cdabf58 into master Dec 3, 2026
16 checks passed
@chaitanyapotti
chaitanyapotti deleted the ci/release-notes-token-isolation branch December 3, 2026 07:38
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