This document explains the security model and permissions used in our GitHub Actions workflows, following the principle of least privilege.
Each workflow and job is granted only the minimum permissions necessary to perform its function. This reduces the attack surface and limits potential damage from compromised dependencies or malicious code.
permissions:
contents: read # Allow reading repository contents
checks: write # Allow writing check runs (test results)
pull-requests: write # Allow commenting on PRs (for coverage reports)Why these permissions?
contents: read- Workflows need to checkout and read the codechecks: write- Required to post test results and status checkspull-requests: write- Needed for automated PR comments (e.g., coverage reports)
NOT granted:
contents: write- Workflows cannot modify code or push commitsactions: write- Cannot modify workflow filesdeployments: write- Cannot trigger deploymentspackages: write- Cannot publish packagespages: write- Cannot deploy to GitHub Pagessecurity-events: write- Cannot modify security alerts
permissions:
contents: read # Read repository code
checks: write # Write test results
pull-requests: write # Comment coverage on PRsPurpose: Run unit tests, generate coverage, post results to PR
Potential risks mitigated:
- Cannot push malicious code back to repository
- Cannot modify other workflow files
- Cannot access repository secrets beyond what's explicitly passed
permissions:
contents: read # Read repository code
checks: write # Write lint check resultsPurpose: Run code quality checks and report issues
Reduced permissions:
- Does NOT have
pull-requests: write- doesn't need to comment on PRs - Only reports check status via GitHub Checks API
permissions:
contents: read # Read repository code
checks: write # Write build check resultsPurpose: Compile the server binary and upload as artifact
Notes:
- Artifact uploads use
GITHUB_TOKENautomatically - Cannot publish artifacts to external registries
- Artifacts are scoped to the workflow run
- Explicit permissions - No implicit permission grants
- Read-only by default - Start with minimal access
- Job-specific permissions - Each job gets only what it needs
- No workflow modification - Workflows can't alter themselves
- Limited PR access - Can comment but not approve/merge
- Artifact isolation - Build artifacts can't access secrets
-
Branch Protection Rules (recommended)
- Require status checks to pass
- Require pull request reviews
- Restrict who can push to main
-
Secret Management
- Never log secrets in output
- Use GitHub's secret masking
- Rotate secrets regularly
- Scope secrets to specific workflows when possible
-
Dependency Security
- Pin action versions to commit SHAs (not tags)
- Review third-party actions before use
- Enable Dependabot for action updates
-
Code Review
- Review workflow changes carefully
- Watch for permission escalation attempts
- Audit third-party action usage
| Permission | Read | Write | Admin | Our Usage |
|---|---|---|---|---|
| actions | β | β | β | None |
| checks | β | β | β | Write (all jobs) |
| contents | β | β | β | Read-only |
| deployments | β | β | β | None |
| issues | β | β | β | None |
| packages | β | β | β | None |
| pages | β | β | β | None |
| pull-requests | β | β | β | Write (test job only) |
| repository-projects | β | β | β | None |
| security-events | β | β | β | None |
| statuses | β | β | β | None |
-
View Workflow Runs
- Go to Actions tab β Select workflow run
- Check "Set up job" logs for granted permissions
-
Audit Logs
- Organization Settings β Audit log
- Filter by actions:
workflows.*
-
Security Alerts
- Enable Dependabot alerts for Actions
- Review CodeQL security scanning results
- Workflows requesting
contents: write - Unexpected
pull-requests: writeon jobs that don't need it - Any request for
actions: writeor admin permissions
- Unexpected workflow file changes
- New workflows without review
- Third-party actions from unknown sources
- Actions pinned to tags instead of SHAs
If you suspect a security issue:
-
Immediate Actions
- Disable the affected workflow
- Rotate any potentially exposed secrets
- Review recent workflow runs
-
Investigation
- Check audit logs for unauthorized changes
- Review workflow file history
- Examine workflow run logs
-
Remediation
- Remove malicious code
- Update permissions to be more restrictive
- Document the incident
- Notify team
- GitHub Actions Security Best Practices
- Automatic token authentication
- Permissions for the GITHUB_TOKEN
- Security hardening for GitHub Actions
This document and workflow permissions should be reviewed:
- Quarterly as part of regular security review
- Whenever new jobs are added to workflows
- After any security incident
- When GitHub updates permission model
Last Updated: October 2025
Owner: Engineering Team
Next Review: January 2026