Code-to-Cloud Attacks: Leaked GitHub Tokens Become Keys to the Kingdom

New "Code-to-Cloud" Attack Vector Sees Threat Actors Pivot From GitHub to Cloud Environments via Leaked PATs

HIGH
December 9, 2025
6m read
Cloud SecuritySupply Chain AttackVulnerability

Related Entities

Organizations

Products & Tech

GitHub GitHub Personal Access Tokens (PATs)GitHub ActionsGitHub Enterprise

Other

Cloud Service Provider (CSP)

Full Report

Executive Summary

Security researchers at the Wiz Customer Incident Response Team (CIRT) have identified a sophisticated attack path they call "code-to-cloud," which allows threat actors to pivot from a compromised code repository into a production cloud environment. This attack leverages leaked or compromised GitHub Personal Access Tokens (PATs). Even a PAT with basic read-only permissions can be used to discover the names of GitHub Action Secrets, which often contain high-value credentials for Cloud Service Providers (CSPs). If the attacker obtains a PAT with write access, they can modify CI/CD workflows to exfiltrate these secrets and gain direct access to the victim's cloud infrastructure. This creates a stealthy and highly impactful attack vector that bypasses traditional network perimeter defenses.


Threat Overview

The attack capitalizes on the tight integration between modern development platforms like GitHub and cloud environments (e.g., AWS, Azure, GCP). The core of the threat lies in the misuse of GitHub PATs, which are often over-provisioned and poorly monitored.

The attack flow proceeds as follows:

  1. Compromise PAT: An attacker obtains a GitHub PAT, either through public leaks, social engineering, or malware.
  2. Discover Secrets: Using the PAT, the attacker queries the GitHub API to list the names of all GitHub Action Secrets within the repository. Critically, Wiz researchers found that these API search calls are not logged in GitHub Enterprise, making this reconnaissance phase invisible.
  3. Exfiltrate Secrets: If the PAT has workflow write permissions, the attacker modifies an existing GitHub Actions workflow file or creates a new one. This malicious workflow is configured to access the discovered secrets and exfiltrate their values to an attacker-controlled server.
  4. Pivot to Cloud: With the exfiltrated CSP credentials (e.g., AWS access keys, Azure service principal credentials), the attacker now has direct access to the victim's cloud environment.
  5. Cover Tracks: The attacker can use the same PAT to delete the malicious workflow file or revert changes to hide their activity.

This threat is exacerbated by poor security hygiene. Wiz data shows that 73% of organizations store CSP credentials in GitHub Action Secrets, and 45% have plain-text cloud keys in private code repositories.

Technical Analysis

This attack chain leverages several MITRE ATT&CK techniques:

Let's refine the TTPs:

Impact Assessment

A successful code-to-cloud attack can be catastrophic, as it bridges the gap between development and production environments. Potential impacts include:

  • Full Cloud Environment Compromise: Attackers can gain administrative access to the cloud environment, allowing them to steal data, deploy ransomware on cloud assets, or disrupt services.
  • Massive Data Exfiltration: Access to production databases and storage buckets can lead to the theft of enormous volumes of sensitive company and customer data.
  • Supply Chain Attack: Attackers could use their access to inject malicious code into the application, which is then deployed to customers.
  • Cryptojacking: Attackers can spin up powerful cloud resources to mine cryptocurrency at the victim's expense.

Cyber Observables for Detection

Type Value Description
log_source GitHub Audit Logs Monitor for PATs being created with overly broad permissions or PATs that have not been used recently becoming active.
api_endpoint GET /repos/{owner}/{repo}/actions/secrets While the search call itself may not be logged, monitor for any available API logs showing access to list secrets.
log_source GitHub Actions workflow logs Look for workflows that are unexpectedly modified, or new workflows that contain commands like curl, wget, or network connections to unknown IPs.
log_source CloudTrail / Azure Activity Logs Correlate GitHub activity with cloud activity. Alert on cloud API calls made from unexpected sources shortly after a CI/CD run.

Detection & Response

  • GitHub Audit Log Monitoring: Regularly review GitHub audit logs for suspicious PAT activity. Look for PATs created without expiry dates, PATs with excessive permissions (repo, workflow), and PATs being used from anomalous IP addresses or geographic locations. This is an application of D3FEND's D3-UGLPA: User Geolocation Logon Pattern Analysis.
  • CI/CD Pipeline Monitoring: Implement monitoring for your workflows directory in GitHub. Alert on any commit that modifies a workflow file, especially those that add new steps involving shell commands or network requests. This is a form of D3-SFA: System File Analysis.
  • Cloud Threat Detection: Use a Cloud Security Posture Management (CSPM) or Cloud-Native Application Protection Platform (CNAPP) tool to detect anomalous behavior in your cloud environment. Correlate alerts with recent GitHub Actions runs. For example, an alert for a new IAM user being created by credentials that are only used in CI/CD is a major red flag.

Mitigation

  1. Adopt OIDC for Cloud Authentication: The most effective mitigation is to stop using long-lived static credentials (like AWS access keys) in GitHub Actions. Instead, use OpenID Connect (OIDC) to establish a trust relationship between GitHub and your CSP. This allows workflows to request short-lived, ephemeral credentials directly from the CSP for each job, eliminating the need to store secrets in GitHub. This is a form of D3-ANCI: Authentication Cache Invalidation.
  2. Enforce PAT Best Practices: If PATs must be used, enforce strict policies:
    • Expiration: Mandate that all PATs have a short expiration date (e.g., 30 days).
    • Least Privilege: Ensure PATs are scoped with the minimum required permissions. A PAT that only needs to read code should not have workflow or write permissions.
    • Fine-Grained PATs: Use fine-grained PATs that can be restricted to specific repositories.
  3. Secret Scanning: Implement automated secret scanning in your pre-commit hooks and CI/CD pipelines to prevent any hard-coded credentials from ever entering the codebase.
  4. Workflow Hardening: Use GitHub features like environment protection rules to require manual approval for workflows that access sensitive environments or secrets.

Timeline of Events

1
December 9, 2025
This article was published

MITRE ATT&CK Mitigations

While not directly protecting PATs, enforcing MFA on GitHub user accounts makes the initial compromise needed to create a PAT much harder.

Mapped D3FEND Techniques:

This is a proxy for identity management. The best mitigation is using OIDC for ephemeral, short-lived credentials instead of static PATs.

Mapped D3FEND Techniques:

Audit

M1047enterprise

Regularly audit GitHub logs for PAT creation, usage from anomalous locations, and modifications to workflow files.

Mapped D3FEND Techniques:

D3FEND Defensive Countermeasures

The most effective defense against this 'code-to-cloud' attack is to eliminate the use of long-lived static credentials like GitHub PATs for cloud access. Implement OpenID Connect (OIDC) between your GitHub repository and your Cloud Service Provider (e.g., AWS, Azure, GCP). Configure a trust relationship that allows GitHub Actions workflows to assume a specific IAM role. This role will then grant short-lived, ephemeral credentials that are valid only for the duration of that specific workflow job. This approach ensures that even if an attacker compromises your repository, there are no persistent cloud credentials to steal. It completely removes the standing privilege that PATs with embedded CSP keys represent, directly mitigating the core threat of secret exfiltration.

For environments where PATs are still in use, implement robust monitoring of their activity. Ingest GitHub audit logs into your SIEM and establish a baseline of normal PAT usage. Create alerts for anomalous patterns, such as: 1) A PAT that has been dormant for a long period suddenly becomes active. 2) A PAT is used from a new or suspicious IP address or ASN. 3) A PAT associated with one repository is used to try and access another. 4) A PAT is used to modify a .github/workflows/ file outside of a pull request process. By analyzing access patterns, you can detect when a legitimate PAT has been compromised and is being used for malicious reconnaissance or to tamper with CI/CD pipelines.

Sources & References

Article Author

Jason Gomes

Jason Gomes

• Cybersecurity Practitioner

Cybersecurity professional with over 10 years of specialized experience in security operations, threat intelligence, incident response, and security automation. Expertise spans SOAR/XSOAR orchestration, threat intelligence platforms, SIEM/UEBA analytics, and building cyber fusion centers. Background includes technical enablement, solution architecture for enterprise and government clients, and implementing security automation workflows across IR, TIP, and SOC use cases.

Threat Intelligence & AnalysisSecurity Orchestration (SOAR/XSOAR)Incident Response & Digital ForensicsSecurity Operations Center (SOC)SIEM & Security AnalyticsCyber Fusion & Threat SharingSecurity Automation & IntegrationManaged Detection & Response (MDR)

Tags

DevSecOpsGitHubCloud SecurityCI/CDPersonal Access TokenPATSupply Chain

📢 Share This Article

Help others stay informed about cybersecurity threats

Continue Reading