# GitHub Actions Security > GitHub Actions runs repo-defined YAML with secrets, a `GITHUB_TOKEN`, OIDC identity and often publish rights. The attack surface is untrusted event input, mutable third-party action refs, stolen tokens that can commit workflows, and runners/caches shared across trust levels. ## How it works Trust model (Wiz): a **trusted zone** (owners, collaborators, approved bots that can push to main, edit workflows and read secrets) and an **untrusted zone** that can still *trigger* workflows through fork PRs, issues, comments, discussions, forks and stars. An attacker gets in by one of three routes: 1. **Circumvention.** Untrusted input steers a privileged workflow. See [[Pwn Requests]] and script injection below. 2. **Third-party component compromise.** A tag of an action you `uses:` is repointed. See [[tj-actions changed-files Compromise]]. 3. **Promotion.** Stolen PATs or maintainer accounts commit workflows directly. In GhostAction/Gheist (Oct 2026), anyone who could commit a workflow file got every secret. Dangerous triggers: no write needed to fire them, and they run in the default-branch context with secrets and write access. | Trigger | Attacker vector | |---|---| | `pull_request_target` | PR content (head checkout, title, branch) | | `issues`, `issue_comment` | title / body / comment | | `discussion`, `discussion_comment` | discussion text | | `fork`, `watch` | attacker-triggered fork / star | | `workflow_run` | inherits poisoned artifacts from parent | ## Techniques / payloads ### Expression (script) injection `${{ }}` is expanded **before** the shell parses the step: ```yaml - run: some-command ${{ github.event.issue.title }} # vulnerable # github.head_ref variant: branch names can't contain spaces, so payloads use $(...) + ${IFS} (Ultralytics) - env: TITLE: ${{ github.event.issue.title }} run: some-command "$TITLE" # safe: data, not code ``` Also avoid writing attacker-influenced data to `$GITHUB_ENV`/`$GITHUB_PATH`, which lets an attacker set `LD_PRELOAD` or shadow binaries in later steps. ### Mutable refs, tag repointing and imposter commits - `@v4` resolves at job start, so a force-pushed tag changes what runs. Cases: tj-actions (Mar 2025, all tags), `trivy-action` (Mar 2026, 76 of 77 tags force-pushed by TeamPCP, which cascaded into LiteLLM on PyPI), and `actions-cool/issues-helper` (2026, every tag moved to an **imposter commit** that only existed in a fork. It ran Bun, read `Runner.Worker` memory and exfiltrated to `t.m-kosche[.]com`, linking it to Mini Shai-Hulud). - A full SHA in `uses:` doesn't prove the commit belongs to the named repo, because fork-network commits resolve under the parent. ### Secret extraction primitives - Read `Runner.Worker` process memory (`/proc/<pid>/mem`) to get every decrypted secret, including ones the step never referenced. - Log masking only matches verbatim values. Base64/base32/JSON-wrapped secrets print in clear (Gheist base32-encoded `toJson(secrets)`, downloaded the log by API, then deleted the run). - `permissions: {}` restricts `GITHUB_TOKEN` **but not secrets**. - `actions/checkout` persists the token in `.git/config` (`persist-credentials: true`), and it can end up in uploaded artifacts. Gato's artifact scanner hunts for these. - Caches: in Rust/Miri, `cargo miri` wrote **all env vars** into `target/`. Caching `target/` then exposed secrets to any PR that could read the cache. ### Self-hosted runners They're non-ephemeral by default, so an attacker who runs code from a fork or PR on a public repo can persist and poison `~/.npm`/`~/.cache/pip` for later release jobs. Gheist added a job that hunted for IMDS creds, Docker sockets and K8s tokens on self-hosted runners. Gato/Trajan enumerate self-hosted runner exposure from workflow files plus run logs. **Egress is open by default.** GitHub's 2026 security roadmap states hosted runners allow unrestricted outbound access; GhostAction's injected workflow sent all repo secrets in one POST to a bare IP. A Nov 2026 survey of hosted runners, ARC 0.15.1, the Terraform AWS runner module, GARM, nine runner vendors, Harden-Runner and the GitLab/Buildkite/Jenkins/Tekton Kubernetes runners found none documenting default-deny egress (Namespace, Depot, Avrea and Harden-Runner offer it as an option; only Avrea documents blocking the metadata server). A Kata microVM isolates the kernel but the cloud metadata server still answers from inside the guest. Default-deny egress does not stop exfiltration through GitHub itself: the prt-scan campaign printed secrets into workflow logs and posted them as PR comments ([[raw/karlkfi.medium.com/your-ci-can-reach-the-whole-internet-why-15956|karlkfi]]). **Forks can pick your runner.** A `pull_request` run executes the merge commit, workflow file included, so a fork can edit `runs-on` to target any runner set the repo can reach; GitHub's approval setting keys on the contributor, not the fork. GitHub's `fork` flag read `true` on a same-repo PR inside a forked repo, so GitHub Actions Gateway (GAG) 2.0 compares head and base repository before minting a runner and refuses mismatches. `pull_request_target` runs the base repo's workflow and is not refused; GitHub blocks it by default in public repos from 2 Dec 2026 ([[Pwn Requests]]). The `hackerbot-claw` bot spent ten days opening crafted PRs against weak workflows, exfiltrated a `GITHUB_TOKEN` and used another stolen token to delete a security scanner's releases ([[raw/karlkfi.medium.com/your-ci-can-reach-the-whole-internet-why-15956|karlkfi]]). ### AI-powered actions - `anthropics/claude-code-action` (12K+ workflows) and `openai/codex-action` trusted any actor ending in `[bot]` (`checkWritePermissions`). Any GitHub App token, or an App registered under an allowed bot's free name ("dangling GitHub Apps"), bypassed the write-access gate. **Dependabot confused-deputy** made `dependabot[bot]` the `github.actor` on attacker PRs. RyotaK's chain reached OIDC tokens through prompt injection and could have backdoored `claude-code-action` itself (CVSS 7.8, exploited in the wild per Anthropic). - Models refuse to leak `secrets.*`, but they will dump credential **files** that other steps create (`google-github-actions/auth` → `gha-creds-*.json`). `show_full_output: true` / `gemini_debug: true` write every tool read to the public log. - GitLost (Noma): an issue in a public repo steered a GitHub Agentic Workflow with org-wide read access into posting a private repo's README as a comment. The word "Additionally" got past the guardrail. - JetBrains Junie GitHub Action < 1.8.0: code execution with workflow credentials via fork updates (CVE-2026-123852). See [[Indirect Prompt Injection]], [[AI Coding Assistant Risks]]. ## Defenses ```yaml permissions: {} # workflow default; grant per job jobs: build: permissions: contents: read steps: - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 with: persist-credentials: false ``` - **Org settings:** read-only default token (orgs created before Feb 2023 default to read-write). Use an allowed-actions list with **SHA-pinning enforcement** and `!org/action` blocking (Aug 2025). Disable "Allow GitHub Actions to create and approve pull requests". - **Pin + cooldown:** pin full 40-char SHAs from the official repo and update through Dependabot/Renovate. A 7–14 day cooldown (`pinact --min-age 7`, Renovate `minimumReleaseAge`) catches most compromises. Transitive composite actions and reusable workflows still float. - **Lockfile (public preview 2026-10-14):** `gh actions-lock` writes `.github/workflows/actions.lock` with the commits of direct and transitive actions, reusable workflows, `owner_id`/`repo_id` and a requirement that the commit is on a source-repo branch. It's enforced by the "Require lockfile" policy. It locks whatever you resolved, **including malware if a tag was already poisoned**. `--accept-moved` should never be automated. Boost Security showed a hand-edited fork-only SHA passing `--verify`. - **Secrets:** don't use `toJson(secrets)` or `secrets: inherit`. Put release credentials in Environments with required reviewers, or in GitHub Apps. Use **OIDC** to the cloud instead of long-lived keys. `::add-mask::` derived values, and never use structured blobs as secrets. 2026 roadmap: scoped secrets bound to workflow identity/branch, and write access no longer grants secret management. - **Execution policy:** Workflow Execution Protections (actor/event rulesets, evaluate mode). Since 2026-07-28, suspicious runs in public repos are held in `action_required`. That hold doesn't apply to private repos or GHES. - **Runners:** use ephemeral runners only. Never use self-hosted runners for public repos. Separate runner groups by trust level. Default-deny egress (Harden-Runner, GitHub native egress firewall, Actions Data Stream telemetry on the roadmap). For Kubernetes runners, GAG's defaults are a reference: per-tenant default-deny NetworkPolicy allowing only cluster DNS and a tenant egress proxy to GitHub's published ranges (admin-managed allowlist), metadata server blocked, fork jobs refused unless a runner set opts in, Pod Security `baseline` (opt-in `restricted`), GitHub App key kept out of worker pods, controllers off worker nodes, Kata for kernel isolation and unprivileged Docker builds ([[raw/karlkfi.medium.com/your-ci-can-reach-the-whole-internet-why-15956|karlkfi]]). - **Lint and enumerate:** `zizmor` (template injection, unpinned uses, dangerous triggers; full YAML-anchor support validated on 41,253 workflows), CodeQL for Actions, OpenSSF Scorecard `Dangerous-Workflow`, `gato`/`trajan`/Gato-X for offensive enumeration, Allstar for policy. - Maintainers: enable **Immutable Releases** so tags and assets can't be rewritten. ## Related - [[Software Supply Chain Security]] - [[Pwn Requests]] - [[tj-actions changed-files Compromise]] - [[CI-CD Pipeline Attacks|CI/CD Pipeline Attacks]] - [[Shai-Hulud Worm]] - [[SBOM and Provenance]] - [[Prompt Injection]] · [[Indirect Prompt Injection]] · [[AI Coding Assistant Risks]] - [[Secrets in Git History]] · [[Leaked Cloud Credentials]] ## Sources - [[raw/wiz.io/primer-on-github-actions-security-threat-model-attacks-and-defenses-pa-4934|Wiz — Primer on GitHub Actions Security]] - [[raw/wiz.io/how-to-harden-github-actions-an-updated-guide-8757|Wiz — How to Harden GitHub Actions: An Updated Guide]] - [[raw/wiz.io/the-in-security-landscape-of-ai-powered-github-actions-part-2-2-8758|Wiz — The (In)security Landscape of AI-Powered GitHub Actions]] - [[raw/docs.github.com/security-hardening-for-github-actions-github-docs-6913|GitHub Docs — Security hardening for GitHub Actions]] - [[raw/github.blog/what-s-coming-to-our-github-actions-2026-security-roadmap-4930|GitHub — Actions 2026 Security Roadmap]] - [[raw/medium.com/github-actions-got-a-lockfile-on-october-14-it-locks-the-code-you-revi-12862|GitHub Actions Got a Lockfile on October 14]] - [[raw/medium.com/pin-your-github-actions-by-commit-sha-and-lock-workflow-permissions-14598|Pin your GitHub Actions by commit SHA and lock workflow permissions]] - [[raw/medium.com/github-actions-turned-against-its-users-how-ghostaction-and-gheist-sto-12973|GhostAction and Gheist Stole CI/CD Secrets]] - [[raw/thehackernews.com/github-actions-supply-chain-attack-redirects-tags-to-steal-ci-cd-crede-8100|THN — actions-cool tags redirected to imposter commit]] - [[raw/blog.rust-lang.org/github-actions-leaking-secrets-when-miri-output-is-cached-12241|Rust — GitHub Actions leaking secrets when Miri output is cached]] - [[raw/blog.trailofbits.com/we-hardened-zizmor-s-github-actions-static-analyzer-8645|Trail of Bits — Hardening zizmor]] - [[raw/github.com/github-praetorian-inc-gato-github-actions-pipeline-enumeration-and-att-6914|praetorian-inc/gato]] - [[raw/esecurityplanet.com/claude-code-github-actions-flaw-created-supply-chain-attack-risk-8457|Claude Code GitHub Actions Flaw]] - [[raw/github.com/jetbrains-junie-github-action-code-execution-with-workflow-credentials-13598|JetBrains Junie GitHub Action advisory]] - [[raw/noma.security/gitlost-a-public-github-issue-can-steer-an-org-s-agentic-workflow-into-10231|Noma — GitLost]] - [[raw/karlkfi.medium.com/your-ci-can-reach-the-whole-internet-why-15956|Your CI Can Reach the Whole Internet. Why?]]