ci: harden GitHub workflow permissions to least privilege (#27414)

## Summary

Hardens GitHub Actions workflow token permissions to address OpenSSF
Scorecard findings.

## Changes

- Default affected workflows to no token permissions (`permissions:
{}`).
- Move required write permissions directly to the jobs that consume
them.
- Document the least-privilege permissions rule in `AGENTS.md`: never
grant write permissions at the workflow top level; scope grants to
`jobs.<id>.permissions`.

## Validation

- `make lint-light` passed locally via pre-commit hooks.

> 🤖 This PR was created with the help of Coder Agents, and needs a human
review. 🧑💻
This commit is contained in:
Atif Ali
2026-07-23 13:03:40 +05:00
committed by GitHub
parent 52a687902f
commit 671173b498
5 changed files with 19 additions and 9 deletions
+6 -5
View File
@@ -22,11 +22,7 @@ on:
- closed
- labeled
permissions:
contents: write
pull-requests: write
# Required to create the release-specific cherry-pick label if missing.
issues: write
permissions: {}
# Prevent duplicate runs for the same PR when both 'closed' and 'labeled'
# fire in quick succession.
@@ -36,6 +32,11 @@ concurrency:
jobs:
cherry-pick:
name: Cherry-pick to latest release
permissions:
contents: write
pull-requests: write
# Required to create the release-specific cherry-pick label if missing.
issues: write
if: >
github.event.pull_request.merged == true &&
contains(github.event.pull_request.labels.*.name, 'cherry-pick')
+3 -2
View File
@@ -7,11 +7,12 @@ on:
pull_request_target:
types: [opened]
permissions:
pull-requests: write
permissions: {}
jobs:
assign-author:
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Harden Runner
+3 -2
View File
@@ -9,11 +9,12 @@ on:
branches:
- "release/*"
permissions:
pull-requests: write
permissions: {}
jobs:
check-cherry-pick:
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Harden Runner
@@ -15,6 +15,8 @@ on:
default: false
type: boolean
permissions: {}
jobs:
publish-mcp:
runs-on: ubuntu-latest
+5
View File
@@ -104,6 +104,11 @@ instructions focused on guardrails that agents should see immediately.
- **Frontend**: Read [Frontend Development Guidelines](site/AGENTS.md)
before changing anything under `site/`. Reuse shared UI primitives when
possible and prefer Storybook stories for component and page testing.
- **GitHub Actions permissions**: Follow least privilege as recommended by
OpenSSF Scorecard. Do not set write permissions at the workflow
(top) level. Default every workflow to `permissions: {}` at the top level
and grant only the specific permissions each job needs under
`jobs.<id>.permissions`.
## Quick Reference