GitHub Security Best Practices for SOC 2 Compliance
Configure branch protection, code review policies, secret scanning, and audit logging in GitHub to satisfy SOC 2 CC8.1 change management controls.
GitHub and SOC 2 CC8.1
SOC 2's Change Management criterion (CC8.1) requires that you develop and implement controls to prevent unauthorized or untested changes from being deployed to production. GitHub is where most development teams implement these controls, making your GitHub configuration a primary evidence source for CC8.1.
Branch Protection Rules
Every repository that deploys to production needs branch protection on the default branch. Required settings:
Navigate to: Repository → Settings → Branches → Add rule
| Setting | Recommended value | Why |
| Require pull request reviews | 1–2 reviewers | Ensures peer review before merge |
| Dismiss stale reviews | Enabled | Forces re-review after new commits |
| Require review from Code Owners | Enabled if CODEOWNERS exists | Ensures domain experts review |
| Require status checks to pass | All CI checks | Prevents merging broken code |
| Require branches to be up to date | Enabled | Prevents stale branches |
| Restrict who can push | Enabled | Prevents direct commits to main |
| Require linear history | Optional | Cleaner audit trail |
Secret Scanning
GitHub's secret scanning detects committed credentials and notifies you automatically. Enable it at the organization level:
Settings → Code security and analysis → Secret scanning → Enable for all repositories
Also enable Push protection to block pushes that contain secrets:
Settings → Code security → Secret scanning → Push protection → Enable
For custom secret patterns (internal tokens, API keys with your own prefix):
Settings → Code security → Secret scanning → Custom patterns → New pattern
Code Scanning (SAST)
Enable GitHub's CodeQL analysis for SAST:
# .github/workflows/codeql.yml
name: CodeQL
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: '0 2 * * 1'
jobs:
analyze:
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- uses: actions/checkout@v4
- uses: github/codeql-action/init@v3
with:
languages: javascript, python
- uses: github/codeql-action/autobuild@v3
- uses: github/codeql-action/analyze@v3
Dependency Review
Block PRs that introduce critical/high vulnerabilities in dependencies:
# .github/workflows/dependency-review.yml
name: Dependency Review
on:
pull_request:
branches: [main]
jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/dependency-review-action@v4
with:
fail-on-severity: high
Audit Log Export
For SOC 2, you need to retain GitHub audit logs for 12 months. Export them via the API:
curl -H "Authorization: Bearer YOUR_TOKEN" \
"https://api.github.com/orgs/YOUR_ORG/audit-log?per_page=100&phrase=action:org" \
| jq '.[] | {action, actor, created_at}'
SecureSpect automatically archives your GitHub audit log and surfaces relevant events (role grants, branch protection changes, direct commits to protected branches) as findings.