Skip to content

ci: declare least-privilege GITHUB_TOKEN permissions - #26

Merged
gonzafg2 merged 1 commit into
mainfrom
ci/least-privilege-workflow-permissions
May 27, 2026
Merged

gonzafg2 merged 1 commit into
mainfrom
ci/least-privilege-workflow-permissions

Conversation

@gonzafg2

Copy link
Copy Markdown
Owner

Summary

Closes the two open CodeQL alerts about workflows that do not declare an explicit permissions: block:

  • Alert #2 — .github/workflows/ci.yml:21 (medium)
  • Alert #4 — .github/workflows/deny.yml:14 (medium)

Both fired the same rule (actions/missing-workflow-permissions). Without an explicit block, the GITHUB_TOKEN used by these workflows inherits the repository's default scope, which is broader than the workflows actually need.

Scope of the change

Workflow Steps Needs write? Permissions set
ci.yml checkout, cargo fmt/clippy/test/build No contents: read
deny.yml checkout, cargo-deny check No contents: read

contents: read is the minimum scope required by actions/checkout and is sufficient for both jobs.

audit.yml is unchanged: it already declares contents: read plus issues: write (the latter only because cargo-audit may file issues). The new blocks here match that established pattern.

Why this reappeared

The two CodeQL alerts on deny.yml from 2026-05-10 were marked fixed when CodeQL's earlier scan did not re-find them, but reappeared on a subsequent scan with no intervening change to the file. An explicit permissions: block is the durable fix.

Test plan

Closes CodeQL alerts #2 (ci.yml) and #4 (deny.yml), both
`actions/missing-workflow-permissions` (medium). Without an explicit
permissions block, both workflows inherit the repository default
GITHUB_TOKEN scope, which is broader than they need.

Neither workflow writes to the repository: ci.yml runs fmt/clippy/
test/build, deny.yml runs cargo-deny check. `contents: read` is the
minimum to allow `actions/checkout` and is sufficient for both.

Matches the pattern already established in audit.yml, which scopes
its broader `issues: write` permission alongside `contents: read`
only because cargo-audit needs to file issues.
Copilot AI review requested due to automatic review settings May 27, 2026 01:55

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

Adds explicit least-privilege permissions: contents: read blocks to ci.yml and deny.yml to resolve CodeQL actions/missing-workflow-permissions alerts. Matches the pattern already established in audit.yml.

Changes:

  • Add workflow-level permissions: contents: read to .github/workflows/ci.yml.
  • Add workflow-level permissions: contents: read to .github/workflows/deny.yml.

Reviewed changes

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

File Description
.github/workflows/ci.yml Restricts GITHUB_TOKEN to read-only contents scope.
.github/workflows/deny.yml Restricts GITHUB_TOKEN to read-only contents scope.

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

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

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

@gonzafg2
gonzafg2 merged commit 60d5265 into main May 27, 2026
8 checks passed
@gonzafg2
gonzafg2 deleted the ci/least-privilege-workflow-permissions branch May 27, 2026 02:06
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