Skip to content

Fork-PR checkouts: stop persisting the write token (follow-up to #1134) - #1143

Merged
berfinyuksel merged 1 commit into
2.4from
sec/checkout-persist-credentials-2.4
Aug 14, 2026
Merged

berfinyuksel merged 1 commit into
2.4from
sec/checkout-persist-credentials-2.4

Conversation

@berfinyuksel

Copy link
Copy Markdown
Contributor

Applies the mitigation Copilot's review flagged as High on #1134, which was merged with that item scoped out.

Problem: under pull_request_target, actions/checkout persists the contents: write GITHUB_TOKEN into .git/config by default. The lint/check-types/build jobs then run fork-controlled code (npm ci lifecycle hooks, npm scripts), which can read that credential and push to the base repo. Gating only the auto-commit step does not protect the token.

Change (6 checkout sites across both shared workflows):

persist-credentials: ${{ !github.event.pull_request || github.event.pull_request.head.repo.full_name == github.repository }}

Same-repo PRs and push/tag runs keep the token — the git-auto-commit steps keep working unchanged (this is the exact condition that already gates them). Fork-PR jobs become read-only: build/lint still run on the refs/pull/<n>/head checkout from #1134, but no credential is on disk.

Deliberately not here: the full restructure (read-only fork jobs + a separate trusted write-back job, as in the upstream reference) — that belongs to the pull_request_target security review in service-operations#1083, where these workflows are now in scope. This PR just removes the cheapest, highest-value part of the attack surface today.

After merge: forward-merge 2.4 → 2026.1 propagates this into 2026.1's copies of the same files (verified they exist there); the files don't exist above 2026.1, so the rest of the chain is ancestry-only.

🤖 Generated with Claude Code

…flows)

Follow-up to #1134, applying the reviewer-flagged mitigation: under
pull_request_target the checkout otherwise persists the contents:write
GITHUB_TOKEN into .git/config, where fork-controlled npm scripts can read
it. Credentials are now persisted only when the head is same-repo — the
same condition that already gates the git-auto-commit steps, which keep
working unchanged. Fork-PR jobs become read-only.

Full restructure (read-only fork jobs + separate trusted write-back job)
stays with the pull_request_target review in service-operations#1083.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings August 14, 2026 13:43
@berfinyuksel berfinyuksel added this to the 2.4.5 milestone Aug 14, 2026
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Prevents fork-controlled frontend jobs from accessing persisted write credentials while preserving existing behavior for trusted runs.

Changes:

  • Disables persisted checkout credentials for fork PRs.
  • Retains credentials for same-repository PRs and non-PR runs.
  • Applies the mitigation to all six checkout sites.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
.github/workflows/shared-npm-publish.yaml Secures both checkout steps.
.github/workflows/shared-frontend-build.yaml Secures all four frontend checkout steps.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@berfinyuksel
berfinyuksel merged commit a2db718 into 2.4 Aug 14, 2026
13 checks passed
@berfinyuksel
berfinyuksel deleted the sec/checkout-persist-credentials-2.4 branch August 14, 2026 13:45
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants