Join our Newsletter — 33% off our NHI Course
Home› Guides› Secret Exfiltration via CI Logs and Mass Branch…
Guide Non-Human Identity (NHI)

Secret Exfiltration via CI Logs and Mass Branch Creation: Detect, Contain and Prevent Token-Driven Secret Dumps

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 18 November 2026 15 min read
On this page

When an attacker holds a GitHub token with write access, they no longer need to steal your secrets from a vault: they can push a throwaway branch, let your own CI runner read every secret the job can reach, print it to the Actions log and download the log before you notice. This guide explains how the 2025 and 2026 waves of this technique worked, how to detect planted branches and short-lived workflow runs, how to contain an incident without missing a secret, and which GitHub settings stop a stolen token from turning into a full secret dump.

The technique matters to non-human identity teams because it sits exactly at the join between two identities: a human or automation token that can push code, and the machine credentials (cloud keys, registry tokens, deployment secrets) that a pipeline is trusted to use. Compromise of the first quietly hands over the second. For the general task of searching existing logs and build artefacts for leaked values, see How to find secrets in CI logs and build artefacts; this page focuses on the deliberate, attacker-driven version of the problem.

Key takeaways

  • GitHub states that any user with write access to a repository has read access to all secrets configured in it. A stolen write token is therefore a secrets-read token for every workflow that token can trigger.
  • The Gheist campaign reported by Wiz in October 2026 pushed ci-sync- branches containing a single workflow that dumped all reachable secrets to the job log in base32, downloaded the log through the GitHub API and deleted the run seconds later.
  • Log masking is a convenience, not a control. GitHub redaction relies on exact matches, so encoded or transformed secret values can appear in full.
  • Because the data leaves through GitHub itself, there is no attacker server to block. Egress filtering on runners does not help when the exfiltration channel is the log download API.
  • Environment secrets behind required reviewers, OIDC trust policies tied to protected branches or environments, and short-lived GitHub App or fine-grained tokens are the controls that break the chain.
  • Containment means rotating every repository, organisation and environment secret the affected repository could use, not only the ones you saw in a log.

How the attack works

The pattern has five steps, and none of them needs a vulnerability in GitHub.

  1. Obtain a token. The attacker acquires a GitHub personal access token, OAuth token or automation credential with write access to one or more repositories. Wiz reports that Gheist tokens came from sources including infostealer logs and tokens exposed in earlier supply chain attacks.
  2. Push a branch. The token pushes a new branch with a single new workflow file. No pull request is opened, so pull request review rules never fire.
  3. Let the push trigger run. The workflow is configured to run on push. GitHub starts it on a runner the repository already trusts, with access to repository and organisation secrets and, if the job names an environment, to that environment's secrets.
  4. Dump to the log. The job serialises the secrets context (for example with toJSON(secrets)), encodes it so exact-match masking fails, and writes it to standard output.
  5. Collect and clean up. The attacker's tool downloads the run log through the API and deletes the run and often the branch. What remains is a gap in history that is easy to overlook.

This maps cleanly to MITRE ATT&CK: the use of a stolen token is Steal Application Access Token followed by use of valid credentials, the harvesting of pipeline secrets is Unsecured Credentials, and later use of the stolen cloud keys is Valid Accounts: Cloud Accounts. Where stolen package registry tokens are used to publish releases, the incident becomes Compromise Software Supply Chain.

GhostAction and Gheist: what the two campaigns showed

Two public campaigns show how the technique evolved from a noisy first version into a quieter one.

GhostAction (2025)

GitGuardian disclosed GhostAction on 5 September 2025. Compromised GitHub accounts pushed a workflow named "Github Actions Security" at .github/workflows/github_actions_security.yml, triggered on push and workflow_dispatch. The attacker first read the secret names used by each victim's legitimate workflows, then hardcoded those names into the malicious file and sent the values in an HTTP POST to an attacker-controlled host. GitGuardian counted 327 affected users, 817 repositories and 3,325 stolen secrets, most commonly DockerHub credentials, GitHub tokens and npm tokens, with PyPI, AWS, Cloudflare and database credentials also taken.

The weakness of that design, from the attacker's side, was the external endpoint. Once the hostname was identified it could be blocked and it stopped resolving the same day.

Gheist (2026)

Wiz named the Gheist campaign after the gheist user agent in the attackers' GitHub API requests and reported tracking it from September 2026. Its design removed the external endpoint entirely:

  • A stolen token pushes a branch named ci-sync- followed by six random characters, adding only .github/workflows/sync-check.yml with the commit message "ci: sync config".
  • The workflow prints the job environment and every secret the job can read, encoded in base32, so GitHub masking does not reliably catch it.
  • It sets an empty permissions block. That limits the job's GITHUB_TOKEN but does nothing to stop the job reading secrets.
  • Some versions run one job per deployment environment, which exposes environment-scoped secrets, often production credentials.
  • The tool downloads the log through the GitHub API and deletes the run seconds later.

Wiz recovered more than 13,500 planted branches from more than 850 compromised accounts, and reported successful runs in private repositories and GitHub Enterprise environments. In some enterprise organisations the tool cycled through several user and automation accounts within minutes, and hours later the organisation's cloud credentials were used to enumerate AWS Secrets Manager. Wiz also notes that GhostAction is a separate campaign using different workflow files, so detections for one will not catch the other.

The lesson for defenders is that the campaign names and file names will change. The durable signal is the shape of the activity: a new branch, a single new workflow file, a push-triggered run that reads secrets, and a run that disappears almost immediately.

Why log masking does not save you

Many teams treat GitHub's automatic secret redaction as a safety net. GitHub's own hardening guidance explains why it is not one:

  • A runner redacts a secret only if a job used it and the runner could access it.
  • Redaction relies on exact matches. GitHub advises registering derived values (a signed JWT, or a Base64 or URL-encoded secret) as secrets too, and never storing JSON, XML or YAML blobs as a single secret.
  • GitHub states plainly that Base64 is not a substitute for encryption.

An attacker who controls the workflow file controls the transformation. Base32, hex, reversing the string, splitting it across lines or compressing it all defeat exact matching. Masking reduces accidental leaks from honest workflows; it does not constrain a malicious one. Design your controls on the assumption that anyone who can run arbitrary workflow code on a branch can read any secret that branch's jobs can reach.

What a stolen write token can actually reach

Before you can contain this attack, you need an accurate map of which secrets a push-triggered workflow on an arbitrary branch can read. Work through the layers:

Secret scopeReachable from an attacker branch?What changes that
Repository secretsYes, for any workflow run in the repositoryMove sensitive values to protected environments or to OIDC federation
Organisation secretsYes, if the repository is in the secret's repository access policyRestrict access to a selected list of repositories
Environment secretsOnly after the environment's protection rules passRequired reviewers, prevent self-review, deployment branch and tag rules, no admin bypass
Cloud roles via OIDCYes, if the trust policy accepts any branch in the repositoryRestrict the subject claim to protected branches or named environments
Self-hosted runner credentialsYes, anything on the machine or its instance roleEphemeral runners, no Docker socket, blocked metadata access

Two details are easy to miss. First, GitHub notes that organisation secrets set with the CLI default to private repositories only, but secrets created in the web interface can be set to all repositories; review the policy on each one. Second, on GitHub Free, Pro and Team plans, required reviewers and wait timers apply only to public repositories, and private or internal repositories need GitHub Pro, Team or Enterprise for environments at all. If your plan does not enforce environment protection on private repositories, environment secrets give no extra protection against this attack.

Detection: finding planted branches and vanishing runs

Detection works best when it targets behaviour rather than one campaign's strings. Combine the following signals.

Repository and audit log signals

  • New branches whose only change adds a workflow file. Legitimate work rarely creates a branch that touches nothing but .github/workflows/. Alert on it, especially when the pusher is an automation account.
  • Runs deleted shortly after completion. Wiz recommends looking for runs on ci-sync-* branches deleted within a minute of finishing. Generalise this to any workflow run deleted within a few minutes of completion by the same actor who triggered it.
  • Burst branch creation. One identity creating branches across many repositories in minutes is a strong signal of token abuse.
  • Unusual user agents and source addresses on API calls that download logs or delete runs. Gheist used the gheist user agent; the next campaign will not, but unfamiliar clients from unfamiliar networks still stand out.
  • Branches that no longer exist. A run in the audit history whose head branch is gone deserves a look, because attackers clean up after collection.

Cloud-side signals

If workflows federate to cloud providers, cloud audit logs can catch abuse even when GitHub history has been cleaned. Wiz recommends checking role assumptions or token exchanges whose OIDC subject includes the attacker's branch prefix. More generally, alert on any federated session whose subject names a branch that is not a protected branch or deployment environment you recognise. Follow this with a hunt for secrets manager enumeration, new access keys and unusual API activity from the same roles in the hours after the run.

Known indicators

For retrospective hunts, the public indicators include the branch pattern ^ci-sync-[0-9a-z]{6}$, the commit message "ci: sync config", the file .github/workflows/sync-check.yml and the gheist user agent for Gheist, and the file .github/workflows/github_actions_security.yml with the commit message "Add Github Actions Security workflow" for GhostAction. Treat these as a starting point and pair them with the behavioural rules above.

Containment and response

When you find a planted branch or a suspicious short-lived run, assume every secret the job could reach is gone. The log may have been deleted, and you cannot prove which values were read.

  1. Revoke the pushing credential first. Revoke the token or app credential that pushed the commit. If it belongs to a person, end their sessions and check their devices for infostealer malware, which Wiz identifies as a common token source.
  2. Freeze further runs. Do not approve held runs from the suspicious branch, and do not run code from it. Temporarily disable Actions on affected repositories if you cannot be sure every malicious branch is gone.
  3. Enumerate reachable secrets. List repository secrets, every organisation secret whose access policy includes the repository, and every environment secret for environments the job could have named. Include cloud roles whose OIDC trust policy would have accepted the run.
  4. Rotate all of them. Rotate every secret on that list, not only the ones you suspect. Prioritise registry and publishing tokens (npm, PyPI, container registries) and cloud keys, because these enable onward supply chain and cloud attacks. For techniques at scale, see Credential Rotation at Scale.
  5. Check downstream use. Review cloud audit logs for use of rotated credentials, review package registries for unauthorised releases, and check whether stolen GitHub tokens were used against other repositories.
  6. Treat self-hosted runners as compromised. If a planted run executed on a self-hosted runner, rebuild the machine and rotate its instance role, as Wiz advises.
  7. Remove artefacts and record evidence. Delete remaining planted branches after capturing branch names, commit SHAs, actor identities and timestamps for the incident record.

GitHub's hardening guidance also says that if an unredacted secret appears in a log you should delete the log and rotate the secret. In this attack the log has usually already been downloaded, so deletion alone achieves nothing.

Prevention: breaking the chain

No single setting stops the technique. The goal is that a stolen write token yields as little as possible.

Reduce what a branch can read

  • Put production secrets behind environments with required reviewers. GitHub makes environment secrets available only after protection rules pass. Enable prevent self-review so the attacker's identity cannot approve its own run, and deselect the option that lets administrators bypass protection rules.
  • Restrict deployment branches. Use deployment branch and tag rules so that only named branches can use a production environment.
  • Tighten organisation secret policies. Grant each organisation secret to a selected list of repositories, never to all repositories by default.
  • Replace stored cloud keys with OIDC. GitHub recommends OIDC to obtain short-lived, well-scoped tokens. Then restrict trust policies to protected branches or environments. Wiz notes that by default the subject includes the branch name only when the job does not use a deployment environment, so write the condition with that in mind. See GitHub Actions OIDC Federation Hardening Guide.

Reduce what a stolen token can do

  • Prefer GitHub Apps and short-lived fine-grained tokens over classic personal access tokens, and scope each to the repositories it needs. See GitHub Personal Access Tokens Security Guide and GitHub Apps vs Personal Access Tokens vs OAuth Apps.
  • Protect workflow files. GitHub recommends adding .github/workflows to CODEOWNERS so changes need designated approval. Note that CODEOWNERS acts on pull requests, so pair it with branch creation and push restrictions where your plan supports them.
  • Keep GITHUB_TOKEN read-only by default. This does not stop secret reads, as Gheist's empty permissions block shows, but it limits what a malicious job can do to the repository itself.

Harden runners

  • GitHub-hosted runners are ephemeral and cannot be persistently compromised. Self-hosted runners can be, and GitHub says they should almost never be used on public repositories.
  • Run self-hosted runners as short-lived machines without Docker socket access or open access to cloud metadata.

Use platform holds where they apply

Wiz reports that since 28 July GitHub holds workflow runs it flags as potentially malicious until a collaborator with write access approves them, that GitHub says this currently applies to public repositories on github.com only, and that every public Gheist run Wiz checked was still waiting for approval. Train maintainers never to approve an unexplained held run, and do not count on the hold for private repositories or GitHub Enterprise Server.

Common failure patterns

  • Trusting masking. Teams assume redaction stops secrets reaching logs, then discover base32 output in a run that was deleted minutes later.
  • Rotating only what was seen. Responders rotate the secrets they found in a recovered log and leave organisation and environment secrets the job could also reach.
  • Environments without enforcement. Production secrets sit in an environment that has no required reviewers, or the plan does not enforce reviewers on private repositories.
  • Broad OIDC trust. Cloud trust policies accept any ref in the repository, so a planted branch receives production cloud credentials without any stored secret at all.
  • Organisation secrets shared with all repositories. One compromised low-value repository exposes a secret used by the most sensitive pipeline.
  • Ignoring automation accounts. Service accounts with broad write access and long-lived tokens are the most valuable targets and the least monitored.
  • Detection tied to one campaign. Rules match a single file name and miss the next variant.

Practitioner checklist

  • Inventory every identity, human and automation, with write access to repositories that hold or can reach production secrets.
  • Replace classic personal access tokens on automation with GitHub Apps or short-lived fine-grained tokens scoped to named repositories.
  • Move production secrets into environments with required reviewers, prevent self-review on and administrator bypass off.
  • Set deployment branch rules on every production environment.
  • Restrict each organisation secret to a selected list of repositories and review the list quarterly.
  • Replace stored cloud keys with OIDC and restrict trust policies to protected branches or environments.
  • Alert on new branches that only add workflow files, on burst branch creation and on runs deleted within minutes of completion.
  • Alert on federated cloud sessions whose subject names an unexpected branch.
  • Write a response runbook that rotates every reachable secret, revokes the pushing token and checks the owner's devices for infostealers.
  • Run self-hosted runners as ephemeral machines without Docker socket or open metadata access.
  • Brief maintainers never to approve an unexplained held workflow run.

Standards and references

Related NHI Mgmt Group resources: How to find secrets in CI logs and build artefacts · GitHub and GitHub Actions Security Guide · GitHub Actions OIDC Federation Hardening Guide · GitHub Personal Access Tokens Security Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.