1. News
  2. Alerts
  3. GitHub · Security
AlertGitHub · Security3 min read

Hackers use stolen GitHub keys to pull secrets from private code

An automated campaign uses stolen GitHub tokens to make private repositories print their own secrets, then deletes the evidence. Here is who is at risk.

By the Dashline deskSource: The Hacker News
Hackers use stolen GitHub keys to pull secrets from private code
Photo: Derrick Coetzee from Berkeley, CA, USA, CC0
Act this week
What happenedAttackers with stolen GitHub tokens are planting workflows that print a repository's secrets into logs, download them, then delete the runs.
Who is affectedTeams with private repositories on GitHub or GitHub Enterprise Server, especially those storing cloud keys such as AWS credentials as secrets.
What to do
  1. 1Look for branches named ci-sync- followed by six characters, and a file called sync-check.yml.
  2. 2Revoke the token that pushed the branch, then rotate every secret the repository could read.
  3. 3Check audit logs for runs deleted by the gheist user agent, and cloud logs for unexpected activity.
  4. 4Limit what each token can reach and require approval for workflow runs where you can.

Attackers are using stolen GitHub login tokens to make private code repositories reveal their own passwords and keys, then erasing the traces. Cloud security company Wiz calls the campaign Gheist. It has worked against private repositories and GitHub Enterprise environments, and as of October 24 it was still running.

How the attack works

A token is a digital key that lets software act as a GitHub user. With a stolen one, the attackers' tool adds a new branch to each repository the token can reach. The branch is named ci-sync- followed by six random characters. It holds one file, sync-check.yml, which starts an automated job.

That job prints every secret it can read, scrambled in a format called base32. GitHub normally hides secrets in its logs, but its own documentation says that is not guaranteed once a value has been changed. The tool downloads the log and deletes the run seconds later. Because the secrets leave through GitHub itself, there is no attacker server to block.

Why it matters

Anyone with write access to a repository can read every secret stored in it, according to GitHub. A stolen token with that access is enough. Secrets often include cloud keys, such as AWS credentials, and some are tied to production systems.

Wiz has recovered more than 13,500 planted branches from more than 850 compromised accounts, from personal projects to enterprise organizations. It does not say how many organizations had secrets exposed. In some enterprise cases, cloud credentials from the same organization were used hours later to look through AWS Secrets Manager. Wiz does not say where those credentials came from or who used them.

Who can relax a little

Since July 28, GitHub has held suspicious workflow runs until someone with write access approves them. Every public Gheist run Wiz checked was still waiting, so its payload never ran. But the hold applies only to public repositories on github.com. Private repositories and GitHub Enterprise Server are not covered, and the hold only catches runs GitHub flags.

What to do

The alert box above lists the steps. The key point is that deleting the planted branch does not undo anything. Every secret the repository could read has to be replaced, and the token that pushed the branch has to be revoked.

What to watch for next

The tokens come from sources such as infostealer logs, which are malware that steals saved logins, and from earlier attacks like the March compromise of the Trivy scanner. Other attackers use the same accounts. Some victims also appear to carry PolinRider, malware that researchers have linked to North Korea.

Around October 19, one version of the tool began targeting self-hosted runners, the machines organizations run themselves to process GitHub jobs. Wiz calls that job buggy and reports no successful run. The campaign is still changing, and about two-thirds of the accounts involved are no longer available on GitHub.

The takeaway

If your private code is on GitHub, check for ci-sync- branches now, and replace every secret a stolen token could have read.

More articles

You should really read these.

Next step

Let’s talk