Hunting Rogue CI Branches After a GitHub Token Theft: Finding Secret-Dumping Runs, Revoking Tokens, Rotating Secrets and Locking Down Actions

2026-11-09 · By H.A

Hunting Rogue CI Branches After a GitHub Token Theft: Finding Secret-Dumping Runs, Revoking Tokens, Rotating Secrets and Locking Down Actions

An incident-response walkthrough with gh CLI for finding ci-sync style branches and runs that print CI secrets, revoking the stolen tokens, rotating exposed secrets and hardening GitHub Actions.

A stolen GitHub token with write access is enough to steal every CI secret its repositories can reach. The attacker pushes a new branch with a workflow that prints the secrets, encoded so GitHub's log masking doesn't catch them, then reads the run log. Researchers tracking the Gheist operation this month counted more than 13,500 such ci-sync branches, with private repositories and self-hosted runners among those hit. This tutorial is an incident-response walkthrough for a GitHub organisation: find rogue branches and runs, read and remove the leaked logs, cut off the tokens, rotate what was exposed, and change settings so a stolen token is worth much less next time.

Prerequisites

gh auth login
gh auth refresh -h github.com -s admin:org,read:audit_log,repo,workflow

Step 1: Find suspicious branches across every repository

Start with the known branch name, then widen the search. Branch names are cheap for an attacker to change.

ORG=your-org
gh repo list "$ORG" --limit 2000 --json nameWithOwner -q '.[].nameWithOwner' > repos.txt

while read -r r; do
  gh api "repos/$r/branches" --paginate -q '.[].name' 2>/dev/null |
    grep -iE '^(ci-sync|ci_sync|sync-ci)' | sed "s|^|$r  |"
done < repos.txt | tee suspicious-branches.txt

For each hit, find out who pushed it and when:

gh api "repos/OWNER/REPO/branches/ci-sync" \
  -q '{sha: .commit.sha, author: .commit.commit.author, committer: .commit.commit.committer}'

Commit author fields can be forged, so treat them as a lead, not proof. The audit log in Step 3 shows which account and token actually pushed.

Step 2: Find workflow runs from branches nobody owns

The more reliable signal is a run on a non-default branch that was triggered by push and that nobody on the team recognises:

while read -r r; do
  def=$(gh repo view "$r" --json defaultBranchRef -q .defaultBranchRef.name)
  gh run list -R "$r" --limit 200 \
    --json databaseId,headBranch,event,workflowName,createdAt,conclusion \
    -q ".[] | select(.event==\"push\" and .headBranch!=\"$def\") |
         \"$r \(.databaseId) \(.headBranch) \(.workflowName) \(.createdAt)\""
done < repos.txt | tee offbranch-runs.txt

Look at every run whose workflow name or branch you don't recognise. Read its log and search for long Base32 or Base64 blobs, which is how the secret-dumping workflows get around masking:

gh run view RUN_ID -R OWNER/REPO --log | grep -nE '[A-Z2-7]{40,}={0,6}|[A-Za-z0-9+/]{60,}={0,2}'

If you find encoded output, assume every secret that workflow could read is compromised. That means repository secrets, organisation secrets shared with the repo, and environment secrets if the job named an environment.

Step 3: Use the audit log to identify the token and actor

On GitHub Enterprise Cloud, the organisation audit log can include Git events, so you can see who pushed:

gh api "orgs/$ORG/audit-log?include=git&phrase=action:git.push+repo:$ORG/REPO&per_page=100" \
  --paginate | jq -c '.[] | {t: ."@timestamp", actor, action, repo, prog: .programmatic_access_type}'

Also look for other activity by the same account, such as new deploy keys, workflow changes and repository creation:

gh api "orgs/$ORG/audit-log?phrase=actor:SUSPECT_USER&per_page=100" --paginate |
  jq -c '.[] | {t: ."@timestamp", action, repo}'

The programmatic_access_type field shows whether the push came from a personal access token, an OAuth app or a GitHub App. That tells you what to revoke.

Step 4: Remove the leaked logs and the rogue branches

Do this after you've saved evidence: run IDs, timestamps and a hash of each log. Then delete the runs so nobody else can read them, and delete the branches:

gh run view RUN_ID -R OWNER/REPO --log > evidence/RUN_ID.log && sha256sum evidence/RUN_ID.log
gh run delete RUN_ID -R OWNER/REPO
gh api -X DELETE "repos/OWNER/REPO/git/refs/heads/ci-sync"

Deleting logs doesn't make the secrets safe again. It only stops further readers. Rotation (Step 6) is still required.

Step 5: Cut off the stolen credentials

What you can revoke depends on the token type:

gh api "orgs/$ORG/credential-authorizations" --paginate |
  jq -r '.[] | "\(.credential_id) \(.login) \(.credential_type) \(.credential_accessed_at)"'
gh api -X DELETE "orgs/$ORG/credential-authorizations/CREDENTIAL_ID"

Step 6: Rotate every exposed secret

Build the list of what the workflow could reach:

gh secret list -R OWNER/REPO
gh secret list -R OWNER/REPO --env production
gh secret list --org "$ORG"

Rotate each secret at its source first, whether that's a cloud key, a registry token or a database password. Then update GitHub:

gh secret set AWS_SECRET_ACCESS_KEY -R OWNER/REPO < new-secret.txt

Afterwards, check each provider's logs for use of the old credential between the rogue run and the rotation.

If self-hosted runners ran the rogue workflow, treat those hosts as compromised. Rebuild them from a clean image instead of cleaning them up.

Step 7: Make the next stolen token worth less

These changes do the most to limit what a stolen token can do:

gh api -X PUT "orgs/$ORG/actions/permissions/workflow" \
  -f default_workflow_permissions=read -F can_approve_pull_request_reviews=false

Verification

Troubleshooting

Wrapping Up

A token-based secret dump finishes within minutes, so how bad it gets depends on what was already in place: secrets locked to environments and protected branches, OIDC instead of static keys, and a read-only default token. Run the hunt now even if you've seen no alert. A five-minute scan for off-branch push runs is cheap, and finding one weeks later is not.

COMPUTE NODE · · --:--:--

Fresh cybersecurity news,
daily threat intelligence.

Daily cyber news, live threat intel and exploited CVEs.

Everything in one place

Self-hosted, hardened, and yours.

RUN IT

Local AI console

Chat with a model on your own hardware via Ollama or any OpenAI-compatible server. No cloud, no key.

DEFEND

Cyber threat feed

Automatic daily intel from CISA KEV, NVD & GitHub advisories, a live cyber threat map, and your own notes.

NEWS

News & videos

Articles and updates on pentesting, AI, and cyber — with embedded video, including YouTube. Post your own.

DIRECTORY

Registry

Runtimes, models, MCP servers, agents, and a full security & pentest tooling section.

PUBLISH

Posts

Write, edit, publish, and share articles backed by a real database and your account.

COMMUNITY

Forum

Threads and replies across categories from Models to Hardware to Security.

CODE

Repos

Curated AI and security GitHub repos, plus a shelf for pinning your own.

DOWNLOAD

Skill packs

Agent starters, RAG scaffolds, and defensive security & VAPT report templates.

Registry

Runtimes, models, MCP servers, agent frameworks, and a security & pentest tooling section — all links out to the real projects.

Local AI console

Talk to a model running on your own machine through Ollama or an OpenAI-compatible server — your prompts and the model's replies always go straight from your browser to your local model, never through a Reef server. Attach files for context, and pick up saved chats where you left off.

Type /image a prompt in the box below to generate
Not connected

Local AI hardware benchmark

A spec-based compatibility advisor — tells you which local models your hardware can run well, which will be slow, and which to skip. Connect to Ollama below for a real, measured speed test instead of an estimate.

1. Your hardware

2. Live check against your local model server (optional)

If a local model server is running, this cross-references the table above with what you've actually got loaded — and runs a real, measured speed test instead of an estimate.

AI Database

A browsable catalog of AI models across providers — context windows, pricing, and capabilities.

Loading…

Cyber threat feed

Latest threats pulled automatically every day from CISA's Known-Exploited-Vulnerabilities catalog and NVD — plus threat intel you post yourself.

⇩ Export STIX
Loading threat feed…

Cyber threat map

Attacks happening right now, all over the world.

Connecting…
LIVE · MAURITIUS TIME--:--:--
attack route, country to country attack route into Mauritius attacker reported worldwide
Loading live data…
attackers reported per minute · click to rewindnow

Top attack routesweb

Attackers based inlast hour

Networkslast hour

Click any dot, feed row or table row to see that IP's profile.

Mauritius

Who attacks Mauritius

Loading…

Web attacks malicious requests to Mauritian websites that were blocked
Network DDoS floods meant to knock Mauritian servers offline

    Mauritius · last 24 h

    How Mauritius is attacked

    Network-level attacks (DDoS) aimed at Mauritius, by method. They try to knock servers and networks offline by sheer volume.

    • Loading…

    The ports or services these floods aimed at aren't published.

    Mauritius · last hour

    Attackers located in Mauritius

    0attackers located in Mauritius were reported in the last hour

    This counts attacks coming from Mauritius, not attacks on it: IPs in Mauritius that servers elsewhere reported for attacking them. Usually zero or one; when it rises, it's often a hacked local server or router.

    Worldwide today

    What attackers are knocking on

    Ports most targeted across a worldwide network of sensors .

    Worldwide today

    Most active attackers

    Ranked by how many separate sensors they hit. Click a row for its profile.

    IPCountryNetworkSensors hitReports
    What you're looking at
    Blue routes

    Share of attack traffic from one country to another. Thicker, faster streams carry more. Particles show volume, not one per attack.

    Every 15 min · published 1–2 h behind
    Amber flashes

    An attacking IP that servers around the world reported in the last minute, placed where the IP is. Its targets aren't published, so there's no line.

    Every minute · shown about 1 min behind
    Locations

    IP locations are approximate (city level at best) and show where the machine is hosted, not who controls it.

    Approximate · city level at best

    News

    Articles, guides and updates on pentesting, AI, and cybersecurity — with embedded video. Add your own, including YouTube.

    Loading…

    Posts

    Loading…

    Loading posts…

    Forum

    Questions, answers, and talk about running AI locally.

    Loading forum…

    GitHub repositories

    Curated AI and security repos, plus your own pinned shelf.

    Command board

    One-liners, configs, and advice worth keeping — shared by everyone here.

    ⚠ Commands are shared with all users. Never include credentials, tokens, or internal hostnames. Review anything before you run it.
    Loading commands…

    Skill packs

    Starter files served from the API — AI agent scaffolds plus defensive security & VAPT reporting templates. Click to download.

    Loading skills…

    Threat Library

    Threat actors, malware and tools — their attack techniques, Reef Sentinel coverage and indicators of compromise.

    Loading…

    Threat Intelligence

    Curated threat write-ups, advisories and analysis — with cover media.

    Loading…

    Tutorials

    Step-by-step guides for running local AI, using the console, and tracking threats. Admins can add their own.

    Loading…

    Downloads

    Direct links to the official homepage/download page for well-known cybersecurity, penetration-testing, and local-AI software. Always verify checksums/signatures from the vendor before running anything.

    Loading…

    Terms & Conditions

    Loading…

    Help & FAQ

    Answers to common questions about Reef Sentinel, plus a formatting guide for posts, articles, and comments.


    Formatting guide

    Commands you can type into the body of a post, comment, or reply — no HTML needed. Comments and short replies only support bold, italic, and inline code.

    Contact us

    Questions, feedback, or a security disclosure? Reach us directly, or send a message and we'll get back to you by email.

    Loading…

    Send a message

    VAPT Report Generator

    Build an engagement, add findings with a live CVSS calculator, and generate a branded, print-ready report.

    Recon Toolkit

    Passive OSINT lookups for the recon phase of an engagement, plus offline hash identification and a payload cheatsheet.

    Website Checker

    Reads a website's HTTP response headers to identify its framework and server, shows any known CVEs for the exposed versions with details, and recommends what to do.

    Control panel

    Manage everything shown on the site — news & videos, posts, homepage headlines, and subscribers. Admin only.

    Overview
    Content
    Site
    Account & Security

    Email settings

    SMTP on ports 25/465/587 is blocked outbound by some hosts (e.g. DigitalOcean droplets by default) — Resend and Brevo send over their HTTPS API instead, so they work even then. Only the selected provider is used to send; the others stay saved but idle, so you can switch back any time without losing settings.

    Get a key from resend.com/api-keys. Uses the "From address" below as the sender — it must be on a domain you've verified with Resend.

    Get an API key (not an SMTP key) from app.brevo.com/settings/keys/api. Uses the "From address" below as the sender — it must be a verified sender in your Brevo account.

    "From address" and "Site name/URL" are shared by SMTP, Resend, and Brevo — they control what recipients see, regardless of which provider is active.

    Send a test email

    Sends through whichever provider is currently active above. Save your settings first if you just changed them.