Skip to content

ci: declare minimum permissions on fork-preview-deploy workflow#1714

Open
arpitjain099 wants to merge 1 commit into
ruby:masterfrom
arpitjain099:chore/declare-workflow-perms
Open

ci: declare minimum permissions on fork-preview-deploy workflow#1714
arpitjain099 wants to merge 1 commit into
ruby:masterfrom
arpitjain099:chore/declare-workflow-perms

Conversation

@arpitjain099

Copy link
Copy Markdown

Declares a top-level permissions block on .github/workflows/fork-preview-deploy.yml with the two scopes the workflow actually uses: actions: read (the actions/download-artifact step pulling from another workflow_run via run-id, and the github-script step calling listJobsForWorkflowRun) and contents: write (the createDispatchEvent API call that triggers the deploy). The workflow runs on workflow_run which executes in the default-branch context with full repo-level token access by default; pinning here keeps that authority bounded.

This is defense-in-depth grounded in CVE-2025-30066 (the March 2025 tj-actions/changed-files supply-chain attack). A compromised third-party action can exfiltrate GITHUB_TOKEN from workflow logs, and the leaked token retains whatever scope it was issued with. workflow_run triggers are particularly attractive because they run trusted and inherit the default scope. The in-file declaration also gives drift protection if the org default ever widens and is what OpenSSF Scorecard's Token-Permissions check credits.

YAML validated locally with yaml.safe_load.

@arpitjain099 arpitjain099 had a problem deploying to fork-preview-protection May 14, 2026 16:58 — with GitHub Actions Failure
Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
@arpitjain099 arpitjain099 force-pushed the chore/declare-workflow-perms branch from 196f55a to 9a91a33 Compare June 10, 2026 07:29
@st0012 st0012 requested a review from Copilot June 14, 2026 16:47

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

This PR tightens GitHub Actions GITHUB_TOKEN privileges for the fork-preview-deploy workflow by explicitly declaring only the permissions needed for its artifact download and REST API calls, reducing default token authority for a workflow_run-triggered workflow.

Changes:

  • Add a workflow-level permissions block restricting the token to actions: read and contents: write.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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