Skip to content

ci: declare least-privilege workflow-level contents: read#23653

Merged
apupier merged 1 commit into
apache:mainfrom
arpitjain099:chore/declare-workflow-perms
Jun 1, 2026
Merged

ci: declare least-privilege workflow-level contents: read#23653
apupier merged 1 commit into
apache:mainfrom
arpitjain099:chore/declare-workflow-perms

Conversation

@arpitjain099
Copy link
Copy Markdown
Contributor

Hardens 3 workflow(s) in this repo by declaring a workflow-level permissions: contents: read. Today those workflows inherit the legacy broad read-write GITHUB_TOKEN; the read-only default reduces blast radius if any step is compromised.

I checked each file - they read the checkout and run tests/lints; no GitHub API writes (no gh pr/issue, no git push, no release/publish/comment actions). So behavior is unchanged.

Reference: the tj-actions/changed-files compromise (CVE-2025-30066) is the canonical reason to apply least-privilege defaults.

Copy link
Copy Markdown
Contributor

@davsclaus davsclaus left a comment

Choose a reason for hiding this comment

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

Thanks for the security hardening effort — least-privilege workflow tokens are a great practice, especially after the tj-actions incident.

However, two of the three workflows perform write operations that will break with only contents: read, because all unspecified permissions default to none when any permissions: key is declared.

pr-commenter.yml calls github.rest.issues.createComment() (line 87) to post a welcome comment, and downloads artifacts via the Actions API. It needs pull-requests: write and actions: read.

pr-labeler.yml uses actions/labeler (line 67) to add labels to PRs, and also downloads artifacts. It needs pull-requests: write and actions: read.

pr-id.yml is fine with just contents: read — it only checks out code and uploads an artifact.

For pr-commenter.yml and pr-labeler.yml, the permissions block should be:

permissions:
  contents: read
  pull-requests: write
  actions: read

This review covers project conventions and correctness. It does not replace specialized review tools such as CodeRabbit, Sourcery, or SonarCloud.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Comment thread .github/workflows/pr-commenter.yml
Comment thread .github/workflows/pr-labeler.yml
These three workflows currently inherit the default read-write GITHUB_TOKEN.
Declare explicit workflow-level permissions instead.

pr-id only checks out the repo and uploads an artifact, so contents: read is
enough. pr-commenter and pr-labeler both download the PR id artifact through
the Actions API (actions: read); pr-commenter then posts a welcome comment via
github.rest.issues.createComment and pr-labeler runs actions/labeler, both of
which write to the PR (pull-requests: write). Scopes were matched to what each
workflow actually does, per review feedback.

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
@arpitjain099 arpitjain099 force-pushed the chore/declare-workflow-perms branch from 9e5fe87 to 1deb423 Compare May 31, 2026 13:30
Copy link
Copy Markdown
Contributor

@davsclaus davsclaus left a comment

Choose a reason for hiding this comment

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

The requested changes have been correctly applied — all three workflows now declare the right permissions:

  • pr-id.yml: contents: read (checkout + upload artifact only)
  • pr-commenter.yml: contents: read + pull-requests: write + actions: read (artifact download + PR comment)
  • pr-labeler.yml: contents: read + pull-requests: write + actions: read (artifact download + PR labeling)

Thanks for addressing the feedback promptly.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

@github-actions
Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@apupier apupier merged commit 7e5f828 into apache:main Jun 1, 2026
3 checks passed
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.

4 participants