GitHub SecurityGitHubBranch ProtectionSASTSecret ScanningCC8

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.

SecureSpect Team··9 min read

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

SettingRecommended valueWhy
|---|---|---|
Require pull request reviews1–2 reviewersEnsures peer review before merge
Dismiss stale reviewsEnabledForces re-review after new commits
Require review from Code OwnersEnabled if CODEOWNERS existsEnsures domain experts review
Require status checks to passAll CI checksPrevents merging broken code
Require branches to be up to dateEnabledPrevents stale branches
Restrict who can pushEnabledPrevents direct commits to main
Require linear historyOptionalCleaner audit trail
Organization-wide policy (recommended): Use GitHub's Rulesets to apply branch protection across all repositories in your org without configuring each one individually.

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.

Automate your SOC 2 evidence collection

Connect your AWS and GitHub environments and start collecting audit-ready evidence today. Free to start.

Start Free →More Articles