Skip to content

ci: add explicit least permissions to workflows#12813

Merged
shreemaan-abhishek merged 2 commits intoapache:masterfrom
shreemaan-abhishek:fix/explicitly-define-workflow-permisions
Apr 10, 2026
Merged

ci: add explicit least permissions to workflows#12813
shreemaan-abhishek merged 2 commits intoapache:masterfrom
shreemaan-abhishek:fix/explicitly-define-workflow-permisions

Conversation

@shreemaan-abhishek
Copy link
Copy Markdown
Contributor

Description

This PR explicitly defines the permissions block for several GitHub Actions workflows that were previously relying on the default (potentially permissive) settings.

By setting permissions: contents: read (and pull-requests: read where necessary), we ensure that the GITHUB_TOKEN used in these workflows follows the principle of least privilege. this acts as a security measure to limit the impact of a compromised workflow step.

With a compromised github token, a bad actor can:

  • Push malicious code directly to the master branch.
  • Create or delete releases and tags.
  • Modify repository settings or secrets (if applicable).

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

Signed-off-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. github_actions Pull requests that update GitHub Actions code labels Dec 13, 2025
@github-actions
Copy link
Copy Markdown

This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 4 weeks if no further activity occurs. If you think that's incorrect or this pull request should instead be reviewed, please simply write any comment. Even if closed, you can still revive the PR at any time or discuss it on the dev@apisix.apache.org list. Thank you for your contributions.

@shreemaan-abhishek
Copy link
Copy Markdown
Contributor Author

.

Copy link
Copy Markdown

Copilot AI left a comment

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 security by explicitly setting GITHUB_TOKEN permissions in workflows that previously relied on repository defaults, applying least-privilege access (primarily contents: read, and pull-requests: read where PR metadata is needed).

Changes:

  • Add explicit permissions: contents: read to multiple workflows to avoid implicitly permissive defaults.
  • Add pull-requests: read to the PR title/semantic workflow to allow PR metadata access under pull_request_target.

Reviewed changes

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

File Description
.github/workflows/semantic.yml Adds explicit read-only token permissions, including PR read access for PR-title validation.
.github/workflows/push-dev-image-on-commit.yml Adds explicit contents: read permissions for checkout/build workflow.
.github/workflows/license-checker.yml Adds explicit contents: read permissions for license header checking workflow.
.github/workflows/check-changelog.yml Adds explicit contents: read permissions for changelog verification workflow.

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

Copy link
Copy Markdown
Member

@moonming moonming left a comment

Choose a reason for hiding this comment

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

Hi @shreemaan-abhishek, thank you for adding explicit least permissions to CI workflows!

This is a security best practice (principle of least privilege). I'll review the specific permission scopes in detail. The approach is correct — explicitly declaring minimum required permissions for each workflow. Please stand by for detailed review.

…-define-workflow-permisions

Signed-off-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
@shreemaan-abhishek shreemaan-abhishek merged commit f8e88f3 into apache:master Apr 10, 2026
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github_actions Pull requests that update GitHub Actions code size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants