Back to all lessons
Awareness Lessons
3 weeks ago

Stolen GitHub Tokens Expose Private Repo Secrets in Gheist Campaign

Written by AI from the linked story. Not reviewed by an editor. How this works

The Gheist campaign demonstrates how stolen access tokens can be weaponized to silently exfiltrate secrets from private repositories, bypassing GitHub's built-in secret masking through encoding tricks. Over 850 accounts were compromised, with malicious workflows injected and then deleted to cover the attacker's tracks, making detection extremely difficult. The core failure lies in over-privileged, long-lived tokens and insufficient controls around CI/CD workflow integrity. This matters because production-grade credentials harvested this way can enable cascading breaches across cloud environments, pipelines, and third-party services.

Tactical Insight

Immediate actions

  • Audit and revoke all existing GitHub personal access tokens and OAuth tokens, replacing them with short-lived, scoped tokens or GitHub Apps with minimal permissions.
  • Scan all repositories and CI/CD workflow files for unauthorized changes or newly injected steps that could exfiltrate environment variables.
  • Enable GitHub's secret scanning alerts and push protection to detect exposed credentials in real time.

Long-term improvements

  • Enforce least-privilege token policies by scoping all GitHub tokens to the minimum required permissions and setting mandatory expiration dates.
  • Implement branch protection rules and required code reviews for workflow files (`.github/workflows/`) to prevent unauthorized injection of malicious CI/CD steps.
  • Rotate all environment-scoped credentials (API keys, cloud credentials, database passwords) that may have been exposed in affected repositories.

Detection measures

  • Enable comprehensive audit logging for GitHub Actions workflow runs, token usage, and branch creation/deletion events, and forward logs to a SIEM for anomaly detection.
  • Set up alerts for unusual branch creation patterns (e.g., mass branch creation by a single actor) and unexpected workflow file modifications.
  • Integrate a secrets management vault (e.g., HashiCorp Vault, AWS Secrets Manager) to replace hardcoded secrets in CI/CD pipelines with dynamically fetched, short-lived credentials.

Back this up with a control

All controls and vendors

Training helps people spot this. These controls make the attack fail even on the day someone does not.