Skip to content

Restrict token permissions in PR validation - #240

Merged
Chetana Kethinedi (ch0707) merged 1 commit into
mainfrom
ch0707-fix-pr-validation-permissions
Oct 16, 2026
Merged

Chetana Kethinedi (ch0707) merged 1 commit into
mainfrom
ch0707-fix-pr-validation-permissions

Conversation

@ch0707

Copy link
Copy Markdown
Contributor

PR validation executes PR-controlled build and test code, so it should not inherit broader GITHUB_TOKEN permissions or leave checkout credentials accessible to subsequent steps.

  • Set workflow-level permissions: contents: read, which is sufficient for checkout and disables other configurable token permissions.
  • Set persist-credentials: false on both checkout steps to remove Git authentication after checkout.

Existing action SHA pins, build/test commands, and artifact handling are unchanged. Artifact uploads and same-run downloads do not require additional GITHUB_TOKEN permissions. This addresses the CWE-732 concern without assuming that current repository defaults grant write access.

Validation: parsed the YAML, verified both checkout settings and read-only permissions, confirmed the remaining workflow matches main, and ran git diff --check. End-to-end execution will occur in PR checks.

Limit GITHUB_TOKEN to contents: read and disable credential persistence on both checkout steps.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: bc09a152-a4a5-4204-a772-94001d65948b

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The targeted security restrictions preserve existing workflow functionality, with no blocking issues identified.

0 open findings

What changed in this PR

Hardens PR validation by restricting token access for PR-controlled build and test code.

Changes:

  • Limits workflow token permissions to contents: read.
  • Disables credential persistence in both checkout steps.
  • Preserves action pins, build/test commands, and artifact handling.
File Description
.github/​workflows/​pr-validation.yml Restricts token permissions and disables checkout credential persistence.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@ch0707
Chetana Kethinedi (ch0707) merged commit fa2ed4a into main Oct 16, 2026
6 of 7 checks passed
@ch0707
Chetana Kethinedi (ch0707) deleted the ch0707-fix-pr-validation-permissions branch October 16, 2026 02:17
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