Skip to content

Add explicit least-privilege permissions to CI workflow#185

Merged
jdneo merged 2 commits into
microsoft:mainfrom
arpitjain099:security/workflow-permissions-ci
May 14, 2026
Merged

Add explicit least-privilege permissions to CI workflow#185
jdneo merged 2 commits into
microsoft:mainfrom
arpitjain099:security/workflow-permissions-ci

Conversation

@arpitjain099
Copy link
Copy Markdown
Contributor

What

Adds explicit permissions: declarations to .github/workflows/ci.yml:

  • workflow-level default: contents: read
  • per-job override on build: contents: write

Why

ci.yml currently does not declare any permissions: block, so GITHUB_TOKEN inherits the repository default token scope. The recommended hardening pattern from GitHub is to declare the minimum scope at the workflow level and override per-job only where a higher scope is actually needed.

In this workflow:

So the workflow-level default is contents: read and the build job overrides to contents: write to keep the dependency-graph upload working. Net effect: the security boundary is documented explicitly, and any future job added at the workflow level inherits the minimum scope by default.

Verification

  • python3 -c "import yaml; yaml.safe_load(open('.github/workflows/ci.yml'))" passes.
  • Existing behavior preserved: Update dependency graph step keeps the contents: write scope it implicitly relied on via the repo default.

Reference

Declare workflow-level contents: read as the default least-privilege scope,
and override per-job to contents: write for the build job because
maven-dependency-submission-action posts to the Dependency submission API
and that endpoint requires contents: write.

This documents the actual scope needed by each part of the workflow rather
than inheriting the repository default token permissions, which is the
recommended hardening pattern.

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
Copilot AI review requested due to automatic review settings May 13, 2026 06:06
Copy link
Copy Markdown
Contributor

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

Adds explicit GitHub Actions token permissions to the CI workflow to document and constrain default GITHUB_TOKEN access.

Changes:

  • Sets workflow-level default permissions to contents: read.
  • Adds a build job permission override to contents: write for dependency graph submission.

Comment thread .github/workflows/ci.yml Outdated
@jdneo
Copy link
Copy Markdown
Member

jdneo commented May 13, 2026

The dependency graph keeps failing actually, maybe we can just remove that step and keep the permission to read

Per @jdneo's review: the 'Update dependency graph' step (maven-dependency
-submission-action) has been failing in CI; removing it lets the workflow
hold to the strict workflow-level contents: read default with no per-job
write override needed.

Net change vs main:
- workflow-level permissions: contents: read (new)
- Update dependency graph step: removed
- per-job permissions: contents: write override on build: not added

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
@arpitjain099
Copy link
Copy Markdown
Contributor Author

Done @jdneo: dropped the Update dependency graph step and removed the per-job contents: write override. The workflow now keeps only the workflow-level permissions: contents: read. Force-pushed.

@arpitjain099 arpitjain099 force-pushed the security/workflow-permissions-ci branch from 9626e9e to 8cc2c11 Compare May 13, 2026 17:13
@jdneo jdneo merged commit d8495cf into microsoft:main May 14, 2026
4 checks passed
@jdneo
Copy link
Copy Markdown
Member

jdneo commented May 14, 2026

Thank you for your contribution!

@jdneo jdneo mentioned this pull request May 15, 2026
19 tasks
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.

3 participants