Skip to content

[sec-check] fix: Token-Permissions — ai-fix.yml deny-all top-level, split pull_request_target to dedicated job#19945

Open
clubanderson wants to merge 2 commits into
mainfrom
sec/fix-workflow-token-permissions
Open

[sec-check] fix: Token-Permissions — ai-fix.yml deny-all top-level, split pull_request_target to dedicated job#19945
clubanderson wants to merge 2 commits into
mainfrom
sec/fix-workflow-token-permissions

Conversation

@clubanderson

Copy link
Copy Markdown
Collaborator

Security Fix

Fixes the pull_request_target Token-Permissions regression in ai-fix.yml.

Changes:

  • Sets permissions: {} at the workflow level (deny-all default)
  • Splits into two jobs to properly isolate pull_request_target from standard triggers:
    • ai-fix job: handles workflow_dispatch and issues: labeled with minimal issues: write scope
    • update-issue-on-pr job: handles pull_request_target (same-repo only) with issues: write + pull-requests: read
  • Pins the reusable workflow to a commit SHA for supply-chain hardening

This eliminates the overly-broad contents: write and pull-requests: write that were granted to all workflow events, including fork-PR pull_request_target events.

Fixes #19944


Filed by sec-check agent (ACMM L6 — full mode)

sec-check added 2 commits June 9, 2026 20:29
…ions: read-all at workflow level

Add top-level `permissions: read-all` to 39 workflows that previously
declared write permissions (issues, pull-requests, contents) at the
workflow level without a restrictive default, violating the principle of
least privilege and the GitHub Scorecard Token-Permissions check.

For single-job and reusable workflows the original write grants are
preserved at the job level. For multi-job workflows the top-level
default is tightened to read-all; existing per-job grants are kept
as-is (jobs that already had per-job permissions are unchanged).

Fixes #17336

Signed-off-by: sec-check <sec-check@hive.kubestellar.io>
Signed-off-by: sec-check <sec-check@hive.kubestellar.io>
Copilot AI review requested due to automatic review settings June 29, 2026 19:56
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Jun 29, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign mikespreitzer for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify

netlify Bot commented Jun 29, 2026

Copy link
Copy Markdown

Deploy Preview for kubestellarconsole ready!

Name Link
🔨 Latest commit 09a78f8
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6a42cdfd1dce1100082e4e5f
😎 Deploy Preview https://deploy-preview-19945.console-deploy-preview.kubestellar.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

Copy link
Copy Markdown
Contributor

🐝 Hi @clubanderson! I'm kubestellar-hive[bot], an automation bot for this repo.

Trusted users — org members and contributors with write access — can mention @kubestellar-hive in a comment to trigger repo automation.
On issues, that mention queues an automated fix attempt. On pull requests, it records extra context for existing automation.
This is not an interactive Q&A bot, so mentions should be treated as requests for automation rather than a conversation.

Automation may take a moment to start, and follow-up happens through workflow activity rather than chat replies.

@kubestellar-prow kubestellar-prow Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 29, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@github-actions

Copy link
Copy Markdown
Contributor

👋 Hey @clubanderson — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

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 hardens GitHub Actions token permissions, primarily to address the Scorecard Token-Permissions finding around pull_request_target usage in ai-fix.yml, by moving away from workflow-level write permissions and scoping writes to only the jobs that need them.

Changes:

  • Updates ai-fix.yml to permissions: {} (deny-all), splits pull_request_target handling into a dedicated job with a same-repo guard, and pins the reusable workflow to a commit SHA.
  • Applies a repo-wide pattern of setting workflow-level permissions: read-all and moving write permissions to job-level blocks.
  • Adds/adjusts job-level permissions across numerous workflows to reduce privilege on events like pull_request_target.

Reviewed changes

Copilot reviewed 39 out of 39 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
.github/workflows/ai-fix.yml Deny-all at workflow level; splits PR-target behavior into a guarded job; pins reusable workflow by SHA.
.github/workflows/workflow-failure-issue.yml Moves write permissions from workflow scope to job scope.
.github/workflows/triage-command.yml Switches workflow default to read-all (but currently missing required job-level writes for issue edits/comments).
.github/workflows/tier-classifier.yml Scopes pull-requests: write to the job and keeps contents read explicit.
.github/workflows/test-coverage-check.yml Scopes PR/issue write permissions to the job.
.github/workflows/stale.yml Scopes issues: write to the job.
.github/workflows/preview-status.yml Scopes pull-requests: write to the job.
.github/workflows/pr-closed-verification.yml Scopes PR/issue write permissions to the job.
.github/workflows/pr-claude-notice.yml Scopes pull-requests: write to the job with same-repo guard.
.github/workflows/post-merge-verify.yml Switches workflow default to read-all (but currently missing required job-level writes for PR/issue reporting).
.github/workflows/perf-ttfi.yml Switches workflow default to read-all and introduces job-level scoping where needed.
.github/workflows/perf-react-commits.yml Switches workflow default to read-all and introduces job-level scoping where needed.
.github/workflows/perf-react-commits-idle.yml Switches workflow default to read-all and introduces job-level scoping where needed.
.github/workflows/perf-bundle-size.yml Switches workflow default to read-all and introduces job-level scoping where needed.
.github/workflows/nil-safety.yml Switches workflow default to read-all.
.github/workflows/nightly-ux-journeys.yml Switches workflow default to read-all.
.github/workflows/nightly-gh-aw-version-check.yml Adds job-level permissions for contents read + issues write.
.github/workflows/nightly-dast.yml Switches workflow default to read-all (but currently missing required job-level issues write for issue creation/updates).
.github/workflows/nightly-dashboard-health.yml Switches workflow default to read-all (but currently missing required job-level issues write for issue creation/updates).
.github/workflows/nightly-compliance.yml Switches workflow default to read-all (but currently missing required job-level issues write/actions read for issue creation + artifact download).
.github/workflows/new-contributor-pr-gate.yml Moves PR/issue write permissions to the guarded job.
.github/workflows/label-helper.yml Moves PR/issue write permissions to the reusable-workflow job.
.github/workflows/kb-nightly-validation.yml Adds job-level permissions for contents read + issues write.
.github/workflows/hive-trust-gate.yml Adds job-level permissions for contents read + issues write.
.github/workflows/ga4-mobile-monitor.yml Adds job-level permissions for contents read + issues write.
.github/workflows/ga4-error-regression.yml Adds job-level permissions for contents read + issues write.
.github/workflows/ga4-error-monitor.yml Adds job-level permissions for contents read + issues write.
.github/workflows/feedback.yml Moves PR write permissions to the reusable-workflow job.
.github/workflows/coverage-weekly-review.yml Adds job-level permissions for contents read + issues write.
.github/workflows/coverage-gate.yml Adds job-level permissions for contents read + PR write.
.github/workflows/copilot-dco.yml Moves PR write permissions to the reusable-workflow job.
.github/workflows/console-issue-labels.yml Moves issues write permissions to the job.
.github/workflows/console-app-smoke.yml Switches workflow default to read-all (but currently missing required job-level issues write for issue creation; fix recommended).
.github/workflows/console-app-roundtrip.yml Adds job-level permissions for contents read + issues write.
.github/workflows/auto-test-gen.yml Adds job-level permissions for contents read + PR write (guarded).
.github/workflows/auth-login-smoke.yml Adds job-level permissions for contents read + issues write.
.github/workflows/assignment-helper.yml Moves issues write permissions to the reusable-workflow job.
.github/workflows/ai-attribution.yml Adds job-level permissions for contents read + PR write.
.github/workflows/add-help-wanted.yml Moves issues write permissions to the reusable-workflow job.
.github/workflows/_perf-regression-issue.yml Adds job-level permissions for contents read + issues write.

permissions:
contents: read
issues: write
permissions: read-all # default read; writes scoped to job below
permissions:
contents: read
issues: write
permissions: read-all # default read; writes scoped to job below
contents: read
issues: write
pull-requests: write
permissions: read-all # default read; writes scoped to job below
permissions:
contents: read
issues: write
permissions: read-all # default read; writes scoped to job below
permissions:
contents: read
issues: write
permissions: read-all # default read; writes scoped to job below
permissions:
contents: read
issues: write
permissions: read-all # default read; writes scoped to job below
@clubanderson

Copy link
Copy Markdown
Collaborator Author

⚠️ This PR has merge conflicts with main after #19950 was merged (both address Token-Permissions by moving permissions to job level). Needs rebase to resolve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tier/3-restricted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[sec-check] Token-Permissions regression: ai-fix.yml uses top-level write permissions with pull_request_target

2 participants