Attack paths
Every GitHub attack has two halves: how the attacker gets in, and what they do once they're there. Pick an attacker goal and the graph shows every way to it: the way in, the GitHub access it uses, the technique, and the defenses (the dots) on the step they break. Hover a box to follow its paths, click one for the details, or pick an incident to see the path it took. Every path ties back to the incidents where they were used.
The source control part (the first three objectives and most entry vectors) follows François Proulx's attack tree for Boost Security, built on the SLSA source integrity threats. The CI/CD, exposure, persistence and GHES paths are drawn from the incidents.
Built from a curated set of 32 incidents, not a measure of how often things happen.
Submit malicious code
T0Get attacker-controlled code onto a branch that gets built and shipped.
Push directly, without review
Attack
There's no branch protection on the target branch, or it doesn't require a review.
Defense
Require a pull request with approvals, status checks and signed commits, and don't let admins bypass it. Leave force pushes and deletions off.
Approve your own PR from a second account
Attack
The attacker talks an owner into granting write access to one or more extra accounts, then opens a PR from one and approves it from another before anyone notices.
Defense
Tie every membership to one person through SSO or Enterprise Managed Users.
Have a workflow approve the PR
Attack
Orgs created before 2022 let GITHUB_TOKEN approve pull requests by default. The attacker adds a workflow to their PR that approves it as soon as it opens.
Defense
Turn off "Allow GitHub Actions to create and approve pull requests" in the org Actions settings.
Push more commits after approval
Attack
The attacker gets a clean change approved, then pushes the bad code to the same PR and keeps the old approval.
Defense
Dismiss stale pull request approvals when new commits are pushed.
Approve someone else's PR, then push to it
Attack
The attacker approves a colleague's good PR, pushes their own bad commit on top, and the colleague's approval or their own covers it.
Defense
Require approval of the most recent reviewable push.
Hide it in a change nobody can review
No setting fully fixes thisAttack
The bad code is buried in a PR touching thousands of lines, or arrives as a new dependency the attacker publishes and controls.
Defense
Keep PRs small, require CODEOWNERS review on lockfiles and manifests, and check every new dependency before it's added.
Use a trusted colleague's account
No setting fully fixes thisAttack
Same as a sock puppet, but with a real senior engineer's account. Reviewers question their changes less.
Defense
The entry-vector controls above (SSO, strong 2FA, short-lived tokens). There's no single fix.
Trick or outlast the reviewer
No setting fully fixes thisAttack
The change uses a bug class the reviewer doesn't know, is written to be confusing, or goes to the reviewer known to approve quickly.
Defense
Require two reviewers on sensitive paths and run SAST, knowing a careful attacker will test against it first. Audit who approves unusually fast.
Bypass or switch off the rules
Attack
An admin merges past branch protection, or turns it off for a few minutes and back on.
Defense
Fewer admins, settings as code, and audit log alerts on protection changes.
Force push or delete a protected branch
Attack
With a weak rule, or as an admin who loosens it for a moment, the attacker rewrites history on the branch.
Defense
Never enable Allow force pushes or Allow deletions on protected branches. Both are off by default.
Delete branches and workflow runs
Attack
After using a stolen token, the attacker deletes the branches and workflow runs they created so the logs are gone.
Defense
Stream the audit log out of GitHub. Workflow runs can be deleted from the repo, but the audit log entries for them stay put.
Push a release tag to an unreviewed commit
Attack
The release pipeline builds on tags like v1.2.3. Pushing a tag only needs write access, so the attacker tags a commit on an unprotected branch, or an old commit with a known bug.
Defense
Add a tag ruleset that restricts who can create, update or delete release tags. The older tag protection rules have been folded into rulesets.
Add a workflow that dumps secrets
Attack
With a token that has the workflow scope, the attacker commits a workflow that sends ${{ toJSON(secrets) }} or named secrets to their own server.
Defense
Protect .github/workflows with CODEOWNERS and a ruleset, keep workflow scope out of PATs, and move secrets into environments with required reviewers.
Run PR code in a privileged workflow
Attack
A pull_request_target or workflow_run job checks out the attacker's PR, or interpolates its title into a shell step, and the attacker's code runs with secrets in scope.
Defense
Treat anything from a PR as untrusted, pass it through env variables, and keep secrets out of those jobs.
Read secrets from the runner
Attack
A backdoored Action or a process on a reused runner reads secrets out of runner memory or from .git/config, and prints them to logs or uploads them as artifacts.
Defense
Pin Actions by SHA, use ephemeral runners, set persist-credentials: false, and don't upload the checkout directory as an artifact.
Steal a session and read secrets from a CI vendor
Attack
Malware on an engineer's laptop takes a 2FA-backed session cookie and uses it to pull customer secrets out of a CI service.
Defense
Use OIDC federation instead of long-lived cloud keys stored in CI, and rotate secrets on a schedule.
No GitHub permission needed. ReachesT1The stolen session reads the deploy and cloud secrets stored in the CI vendor.
Prompt an AI step in a workflow
Attack
A workflow hands an issue title, comment or PR text to an AI agent step that has shell tools. Text written as instructions makes the agent run the attacker's commands inside the job, with its token, secrets and cache access.
Defense
Give AI steps in workflows read-only tools and a read-only token, and keep them out of jobs that hold secrets or write caches a release job restores.
No GitHub permission needed. ReachesT1The agent runs the attacker's commands in the job, with its token and secrets, as a pwn request would.
Search the repository and its history for keys
Attack
With read access the attacker searches the files and every past commit for cloud keys, API tokens and connection strings. A key deleted in a later commit is still in the history, and still works until it is rotated.
Defense
Turn on secret scanning, which also scans history, and rotate every key it finds instead of only deleting the commit. Give workflows cloud access through OIDC so there are no stored keys to find.
Post stolen data to a new public repository
No setting fully fixes thisAttack
Malware holding a developer's GitHub token creates a public repository in the victim's own account and commits what it stole there. The data leaves over github.com, which few networks block, and anyone can read it.
Defense
Keep repo and workflow scopes out of tokens left on developer machines, and give them short lifetimes. With Enterprise Managed Users, member accounts cannot create public repositories at all.
Poison a shared Actions cache
Attack
A default-branch workflow that runs pull request code, such as pull_request_target, writes a cache entry that the release workflow later restores, so attacker-controlled files end up in the release build.
Defense
Don't run pull request code in workflows triggered on the default branch, and don't restore caches in release workflows at all.
No GitHub permission needed. ReachesT1The poisoned cache runs in the release job, with its secrets and its right to publish.
Trigger the publish workflow from a tampered branch
Attack
With a write token, the attacker creates a branch with a modified CI script and starts the publish workflow against it through workflow_dispatch.
Defense
Lock publish workflows to protected branches or tags with deployment environments, and publish with OIDC trusted publishing instead of a stored registry token.
Backdoor a persistent self-hosted runner
Attack
Code from a fork PR runs on a self-hosted runner that isn't wiped afterwards, and stays there for the next release job.
Defense
Use ephemeral self-hosted runners, and don't attach them to public repositories.
No GitHub permission needed. ReachesT1A runner that is not wiped hands every later job on it, with that job's secrets and token, to the attacker.
Publish a malicious version with a stolen token
Attack
A stolen npm or PyPI token is used to publish a new version with an install script that steals the next victim's tokens.
Defense
Publish only from CI with trusted publishing, behind an environment with required reviewers, and turn on 2FA for the registry account. Provenance shows which commit was built, not that anyone approved it, so the branch and tags the workflow builds from need protecting too.
Release through the project's own pipeline
Attack
With push access to the branch releases are built from, the attacker commits the payload and creates a release. The project's publish workflow builds it, so the package carries valid provenance and trusted publishing accepts it without any stolen registry token.
Defense
Require review on the branch releases are built from, protect release tags with a ruleset, and put the publish job behind an environment with required reviewers. Provenance proves where a package was built, not that anyone approved the change.
Hide the payload in a commit only its hash reaches
No setting fully fixes thisAttack
The attacker pushes a commit that is on no branch, or puts it in a fork. GitHub serves any commit in a repository's fork network by its hash under the parent repository's name, so an install script, npx or an Action reference fetches it from a name people trust.
Defense
Check that every pinned Action hash is on a branch or tag of its own repository (zizmor's impostor-commit audit), and alert on pushes nobody expected. No setting stops a fork's commit being served this way.
No GitHub permission needed. ReachesT1The payload runs wherever the pinned Action or install script runs: CI jobs that hold secrets.
Clone private repos with a stolen token
Attack
A leaked PAT or OAuth token with repo read is enough to clone everything its owner can see.
Defense
Short-lived, fine-grained tokens with an IP allow list, and alerting on unusual clone volume.
Flip private repos to public
Attack
An owner or admin token is used to change visibility on many repos at once.
Defense
Restrict repository visibility changes to org owners, keep owner accounts few, and alert on visibility changes in the audit log.
Get an agent to copy private code into public
Attack
A public issue tells an AI agent to read a private repo and post what it finds somewhere public.
Defense
Scope agent tokens to one repository and require approval before an agent writes anywhere.
Add a guest collaborator or new app
Attack
The attacker adds an outside collaborator, a deploy key, or an OAuth grant that survives a password reset.
Defense
Only let org owners invite outside collaborators, and alert on new collaborators, deploy keys and app installs.
Register the attacker's machine as a runner
Attack
The infected host registers itself as a self-hosted runner and plants a workflow that runs commands on it when triggered.
Defense
Limit who can register runners, use runner groups, and review the runner list regularly.
Leave a dormant workflow behind
Attack
The attacker replaces a workflow with one that only runs on workflow_dispatch. Nothing happens until they trigger it through the API, long after the push that planted it has scrolled out of view.
Defense
Require code owner review for .github/workflows, and alert on new or changed workflows and on workflow_dispatch runs nobody expected.
Plant editor or agent config that runs on open
Attack
The attacker commits a .vscode/tasks.json task that runs when the folder opens, or a Claude Code settings file with a session hook. Whoever opens the repository in that editor or starts the agent there runs the attacker's code, after the stolen token is long revoked.
Defense
Protect .vscode/, .claude/ and other agent config paths with CODEOWNERS and a push ruleset, keep VS Code workspace trust on, and decide which coding agents may run on the organization's repositories.
Forge a login
Attack
A SAML signature bug lets an unauthenticated attacker sign in as any user, including a site admin.
Defense
Patch GHES quickly. CVE-2024-4985 was in the optional encrypted assertions feature, so it only applied where that was turned on.
No GitHub permission needed. ReachesT0Signing in without credentials gives full control of the GitHub Enterprise Server instance.
Escalate from a GHES role to root
Attack
A Management Console editor, an enterprise admin editing pre-receive hooks, or even a user with push access abuses a bug to run commands as root.
Defense
Patch GHES, and restrict Management Console and pre-receive hook access to as few people as possible.
No GitHub permission needed. ReachesT0Root on the appliance controls every organization and repository on the instance.
Member with write access
Way in · Insider
Someone who can already push to the repository. Their reach is exactly what branch protection and rulesets allow; without them, write access means pushing straight to the default branch.
Repository admin or org owner
Way in · Insider
Admins can bypass or switch off every control that protects the repository, then turn it back on afterwards. Most of the techniques below get easier or become trivial from here.
Defense
- Manage org and repo settings as code (for example with the GitHub Terraform provider) or through an internal GitHub App, so changes go through review instead of a person's admin rights.
Leaked token
Way in · External, via a stolen identity
A personal access token, npm token, or workflow token found in a dotfile, a CI manifest, a public artifact, a log, or a machine infected by a stealer. A classic PAT with the repo scope is the most valuable find because it works everywhere the owner has access.
Defense
- Require organization owner approval for fine-grained PATs.
- Never upload the checkout workspace as an artifact.
Phished or hijacked account
Way in · External, via a stolen identity
Password reuse, phishing, a malicious OAuth consent screen, device-code phishing, or a stolen browser session. A session cookie skips 2FA entirely, and an OAuth grant keeps working after the password is changed.
Compromised GitHub App or OAuth integration
Way in · External, via a stolen identity
A vendor's integration gets breached, or its private key leaks, and every org that installed it is exposed at whatever permission level it was granted.
Defense
- Scope installations to specific repositories rather than all repositories.
Stolen SSH or deploy key
Way in · External, via a stolen identity
A user's SSH key or a deploy key with write access, taken from a laptop or a server. Git over SSH doesn't prompt for 2FA.
Defense
- Keep keys in an SSH agent with a passphrase, or in hardware or a secure enclave (Secretive on macOS, smart cards, FIDO keys).
- Use an SSH certificate authority at the org or enterprise level so keys expire.
Untrusted input reaches a privileged workflow
Way in · External, via the supply chain and CI/CD
A fork pull request, branch name, issue title or comment is run or interpolated by a workflow that has secrets or a write token. pull_request_target, workflow_run and issue_comment triggers are the usual suspects, along with non-ephemeral self-hosted runners that public PRs can reach.
Defense
- Pass untrusted values through env variables instead of ${{ }} expressions in run steps.
- Make self-hosted runners ephemeral.
- Lint workflows with zizmor or a similar tool in CI.
Compromised Action or package
Way in · External, via the supply chain and CI/CD
A third-party Action or npm/PyPI package you depend on is backdoored upstream. It runs with whatever your workflow or developer machine has in scope.
Defense
- Review new dependencies in PRs and hold new package versions for a few days before they're allowed in (a cooldown).
- Disable install scripts where you can (npm ignore-scripts).
Compromised developer tool or extension
Way in · External, via the developer endpoint
A backdoored IDE extension, CLI or other local tool runs on a developer's machine and takes whatever that machine can reach: tokens, SSH keys, browser sessions and cloned code. Extensions update themselves, so one bad release reaches every install within minutes.
Defense
- Allow-list IDE extensions centrally and block the rest.
- Hold new extension and tool versions for a few days before they install (a cooldown).
- Work on sensitive repositories in Codespaces or dev containers instead of on the laptop.
Prompt injection into an AI agent
Way in · External, via the supply chain and CI/CD
An agent holding a GitHub token reads attacker-written text (an issue, a PR description, a file) and follows it, using the token for things its user never asked for.
Defense
- Give agents a token scoped to the single repository they're working on.
- Don't let an agent read public input and write to private repos in the same session.
Vulnerability in GitHub Enterprise Server
Way in · External, via the platform
A bug in a self-hosted GHES instance: an authentication bypass, or a way to turn a low-privilege role or plain push access into root on the appliance.
Defense
- Keep the Management Console and admin SSH off the general network.
Change a workflow, get its secrets
Commit a workflow, or change an existing one, that runs on push and sends the repository's secrets out. The workflow also sets its own token permissions, including id-token: write.
Gains Every secret the repository's workflows can read, and cloud access through OIDC.
Tested: GitHub Docs: secure useTested 2026-10-28 in a test organization: With the organization's default workflow permissions set to read, a job with permissions: contents: write created a tag, and the same job without the key got 403.
Change what an existing workflow runs, get its secrets
Push a new branch that changes a file an existing push workflow runs: a build script, a test, a package manifest, or a local action outside .github/workflows. The workflow file stays as it is, so no Workflows permission is needed. A push made with a GITHUB_TOKEN starts no run, so this takes a personal token, an App token or a person's own push.
Gains The secrets that workflow uses, from the repository and the organization. Environment secrets too, when a job names an environment whose branch policy lets the new branch through and that has no required reviewers.
Inferred from: GitHub Docs: secure use, GitHub Docs: trigger a workflow
Send a repository_dispatch payload to a workflow with secrets
Send a repository_dispatch event with a client_payload you write. It runs the default branch's workflows on that event with their secrets, and unlike a push it starts a run even when sent with a GITHUB_TOKEN. The payload is only a way in when the workflow puts it into a shell or checks out the ref it names.
Gains The secrets of the workflow on repository_dispatch, when it trusts the payload.
Documented: GitHub Docs: repos, GitHub Docs: trigger a workflow
Open an environment's protection rules
Remove the environment's required reviewers, widen its deployment branch policy, or force a run through with the administrator bypass, which is on unless the environment turns it off. It still takes a way to run a job that names the environment, such as Workflows: write or a push a workflow already acts on.
Gains The environment's secrets, usually the production deploy credentials, with nobody asked to approve.
Documented: GitHub Docs: deployments and environments, GitHub Docs: environments
Share an organization secret with a repository you control
Add a repository whose workflows you can change to an organization secret shared with selected repositories. The value is never needed: the next workflow run in that repository receives it and can send it out.
Gains The value of every organization Actions secret, without reading any of them through the API.
Inferred from: GitHub Docs: secrets, GitHub Docs: secure use
Create a deployment that starts the deploy workflow
Create a deployment for a branch or commit you chose. A workflow on the deployment event runs at that commit, and its job gets the environment's secrets unless a deployment branch policy or required reviewers stop it.
Gains The deploy job's secrets and cloud access, running code nobody reviewed.
Inferred from: GitHub Docs: deployments, GitHub Docs: events that trigger workflows
Sign provenance for your own artifact
Push a workflow with id-token: write and attestations: write that attests any file you give it. The certificate names this repository and the new workflow, so a verifier that checks only the owner or repository accepts it; one that also pins the signer workflow does not.
Gains A forged artifact that passes provenance checks, wherever consumers verify with gh attestation verify --owner or --repo alone.
Inferred from: cli.github.com/manual/gh_attestation_verify, GitHub Docs: artifact attestations
Start a privileged publish job by hand
Run the publish workflow with workflow_dispatch against a branch whose build script was changed.
Gains Whatever the publish job holds: package registry tokens and the right to publish.
Inferred from: GitHub Docs: manually run a workflow
Switch a repository's OIDC subject to match another cloud trust
Opt the repository into the organization's subject template, back to the default, or into its own list of claims. A cloud trust written for a template that does not name the repository, such as one built from repository_owner and context, then accepts tokens from a workflow here that already requests one.
Gains The credentials of a cloud role the repository was not meant to reach.
Inferred from: GitHub Docs: oidc, GitHub Docs: oidc
Flip private repositories to public
Change repository visibility, one repository at a time or in bulk with an owner token.
Gains Private source code exposed to everyone.
Documented: GitHub Docs: setting repository visibility
Register a self-hosted runner
Create a runner registration token or a just-in-time configuration and register a machine the attacker controls, with the labels existing jobs ask for. A job goes to any available runner in its group that has all its labels.
Gains Every job routed to that runner, with the secrets those jobs receive, and a foothold that outlives the stolen token.
Documented: GitHub Docs: add runners, GitHub Docs: use in a workflow
Bake a backdoor into a custom runner image
Add a repository whose workflows the attacker can change to the runner group that builds a custom image, then push a branch with a snapshot job. Each successful run adds a version, and larger runners set to the latest version install it.
Gains Code in every later job on runners that use the image, in every repository allowed to use them, with those jobs' secrets.
Inferred from: GitHub Docs: use custom images, GitHub Docs: self hosted runner groups
Add a collaborator or guest that outlives the attack
With Administration (write), add an account the attacker controls as a collaborator on the repository, or add a deploy key. With Members (write), invite that account to the organization and add it to a team that already has repository access.
Gains Access that survives password resets and token revocation.
Documented: GitHub Docs: collaborators, GitHub Docs: members
Edit the organization role you hold
From: A custom organization role that includes Manage custom organization roles
Edit the same role to add the Admin base repository role and any other organization permission. The permission cannot assign roles, but the holder already has this one.
Gains Admin on every repository in the organization, for the attacker and for everyone else who holds the role.
Inferred from: GitHub Docs: about custom organization roles
Install your own App in an enterprise organization
Register a public GitHub App that asks for organization administration and members, then install it in an organization the enterprise owns with access to all repositories.
Gains Those permissions in that organization, held by a private key the attacker owns, which outlives revoking the enterprise App that installed it.
Inferred from: GitHub Docs: organization installations
Add yourself to a team with repository access
From: The Team maintainer role on a team with repository access
A team maintainer adds an account they control to their team.
Gains Every repository role the team holds, often Write or Admin on production repositories.
Documented: GitHub Docs: assigning the team maintainer role to a team member
Harvest leaked secrets from scanning alerts
List the secret scanning alerts. Each one includes the leaked value, and many are still valid.
Gains Live credentials found in code and history: cloud keys, tokens and passwords, often for systems outside GitHub.
Documented: GitHub Docs: secret scanning
Join any organization as an enterprise owner
From: The Enterprise owner role
An enterprise owner can join any organization owned by the enterprise as a member or as an organization owner.
Gains Organization owner in every organization of the enterprise, even ones they were never added to.
Documented: GitHub Docs: managing your role in an organization owned by your enterprise
Claim the old name of a renamed Action
From: An Action or reusable workflow whose owner renamed or deleted their account or repository
Register the freed owner or repository name and publish code at the same path. Workflows that still use the old owner/repo@ref fetch the new owner's code.
Gains Code running in every workflow that still uses the old path, with its secrets and GITHUB_TOKEN.
Inferred from: GitHub Docs: renaming a repository
Take the workflow token from a runner
From: Code already running in a workflow job: a compromised Action, dependency or pull request
Read GITHUB_TOKEN from runner memory, or from the git credentials actions/checkout leaves on the runner unless persist-credentials is false: in .git/config, or in a file under $RUNNER_TEMP in newer versions.
Gains The job's token, often with write access to the repository.
Documented: github.com/actions/checkout
Poison a cache the release build restores
From: Code running in a workflow on the default branch, such as a pull_request_target job that checks out the pull request. A pull_request run from a fork cannot do it: its caches are scoped to the pull request.
Write a cache entry under a key the release workflow later restores. Caches are not signed, and runs on other branches restore what the default branch saved.
Gains Attacker files inside the release build, and with them the release job's credentials.
Inferred from: GitHub Docs: dependency caching
Persist on a non-ephemeral self-hosted runner
From: A pull request from a fork that runs on a self-hosted runner that is not wiped between jobs
Leave a process or file behind that the next job, often a release, picks up.
Gains The next jobs on that runner, with their secrets and tokens.
Documented: GitHub Docs: secure use
Incidents by path
Each incident, newest first, with the way in and what the attacker went after.