Skip to content

Emit workflow-level permissions from frontmatter instead of always using empty block#14461

Closed
Copilot wants to merge 4 commits intomainfrom
copilot/add-permissions-blocks-to-workflows
Closed

Emit workflow-level permissions from frontmatter instead of always using empty block#14461
Copilot wants to merge 4 commits intomainfrom
copilot/add-permissions-blocks-to-workflows

Conversation

Copy link
Contributor

Copilot AI commented Feb 8, 2026

14 workflows with risky trigger events (issues, issue_comment, pull_request_target) had permissions: {} at workflow level, which defaults to write permissions. Poutine scanner flagged this as default_permissions_on_risky_events.

Changes

  • Compiler: Modified pkg/workflow/compiler_yaml.go to parse frontmatter permissions and render them at workflow level instead of hardcoded permissions: {}
  • Workflows: Recompiled 14 affected workflows with explicit read-only permissions
  • Tests: Fixed TestGenerateYAMLRefactored to expect actual permissions instead of empty block

Before/After

Before:

permissions: {}  # Defaults to write

After:

permissions:
      contents: read
      issues: read
      pull-requests: read

All workflows now follow principle of least privilege with explicit read-only scopes.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Code Quality] Add explicit permissions blocks to workflows using risky trigger events</issue_title>
<issue_description>## Description

14 workflows are triggered by risky events (e.g., pull_request_target) but do not explicitly restrict GITHUB_TOKEN permissions. By default, these workflows run with write permissions, which could be exploited if an attacker can influence workflow execution.

This is a security best practice issue identified by Poutine supply chain security scanner with severity level "Warning".

Affected Workflows

Source files (.md) that need explicit permissions added:

  • ai-moderator.md
  • archie.md
  • brave.md
  • cloclo.md
  • grumpy-reviewer.md
  • mergefest.md
  • pdf-summary.md
  • plan.md
  • pr-nitpick-reviewer.md
  • q.md
  • scout.md
  • security-review.md
  • tidy.md
  • unbloat-docs.md

Suggested Changes

Add explicit permissions: blocks to each workflow's frontmatter following the principle of least privilege:

Example for PR workflows:

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

Common permission patterns:

  • Read-only workflows: permissions: { contents: read }
  • Comment on PRs/issues: Add pull-requests: write and/or issues: write
  • Create releases: Add contents: write
  • No permissions needed: permissions: {}

Files Affected

All 14 workflow source files listed above in .github/workflows/

Success Criteria

  • All 14 workflows have explicit permissions: blocks in frontmatter
  • Each workflow follows principle of least privilege (only permissions needed)
  • Recompiled .lock.yml files include permission restrictions
  • Poutine scanner no longer reports default_permissions_on_risky_events warnings
  • All workflows still function correctly after adding restrictions

Security Impact

Medium - Reduces attack surface by preventing privilege escalation if workflow execution is compromised. Follows GitHub Actions security best practices for workflows triggered by untrusted actors.

Source

Extracted from Static Analysis Report discussion github/gh-aw#14429

Finding: "Top Priority Issue: default_permissions_on_risky_events" - 14 workflows using risky trigger events without explicit permission restrictions.

Priority

Medium - Security best practice that reduces risk, but no active exploit exists. Should be addressed before release to improve security posture.

AI generated by Discussion Task Miner - Code Quality Improvement Agent

  • expires on Feb 9, 2026, 5:26 AM UTC

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits February 8, 2026 05:41
- Modified compiler to render permissions at workflow level instead of always using empty permissions
- All 14 affected workflows now have explicit permissions following principle of least privilege
- Permissions are parsed from frontmatter and rendered as workflow-level permissions in compiled .lock.yml files
- Maintains backward compatibility: workflows without permissions get empty permissions block ({})
- All tests passing, code formatted and linted

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Updated TestGenerateYAMLRefactored to expect actual permissions instead of empty permissions block
- Test now correctly expects "permissions:" and "contents: read" when permissions are defined
- All unit tests passing

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…ing empty block

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add explicit permissions blocks to workflows with risky triggers Emit workflow-level permissions from frontmatter instead of always using empty block Feb 8, 2026
Copilot AI requested a review from pelikhan February 8, 2026 05:54
@pelikhan pelikhan closed this Feb 8, 2026
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.

[Code Quality] Add explicit permissions blocks to workflows using risky trigger events

2 participants