How-To Guide8 min read·

Harden CI/CD Pipelines After Trivy GitHub Actions Breach: Step-by-Step Guide

GS
GhostShield Security Team
GhostShield VPN
A professional analyzing data on multiple monitors in a dark room, highlighting cybersecurity themes.
Photo by Tima Miroshnichenko on Pexels
Continue reading

The Trivy GitHub Actions Breach 2026: How Attackers Stole Secrets from 75 Hijacked Tags

In early 2026, the cybersecurity community was rocked by a sophisticated supply chain attack targeting Trivy, the popular open-source vulnerability scanner. Attackers hijacked 75 GitHub Actions tags—including versions like v0.45.0 and v0.46.1—to distribute malicious versions of the tool. These compromised workflows were then used to steal CI/CD secrets, including API keys, cloud credentials, and tokens, from thousands of organizations.

The breach exposed a critical weakness in CI/CD security: over-reliance on static secrets and overly permissive workflows. With 90% of Fortune 100 companies using GitHub Actions (per GitHub’s 2025 Octoverse report), the attack served as a wake-up call for DevOps and security teams worldwide.

If you’re using GitHub Actions—or any CI/CD pipeline—this guide will walk you through exactly how to harden your workflows to prevent similar breaches. We’ll cover auditing for vulnerabilities, rotating exposed secrets, enforcing least-privilege access, and replacing static credentials with OpenID Connect (OIDC).


Step 1: Audit Your GitHub Actions Workflows for Vulnerabilities

Drone top view of big shabby old metal ventilation fans on factory among pipes Photo by Tom Fisk on Pexels

The first step in securing your CI/CD pipeline is identifying compromised or risky workflows. The Trivy breach exploited unpinned dependencies and overly permissive actions, so your audit should focus on these areas.

How to Identify Compromised Workflows

  1. Check for Malicious Trivy Tags

    • The attackers hijacked 75 tags of the aquasecurity/trivy-action repository. If your workflows reference any of these (e.g., uses: aquasecurity/trivy-action@v0.46.1), they may be compromised.
    • Use GitHub’s Dependabot alerts to detect malicious versions. If you see warnings like trivy-action@malicious-tag, immediately update to a trusted version (e.g., aquasecurity/trivy-action@sha256:...).
  2. Scan for Suspicious uses: Statements

    • Attackers often replace legitimate actions with malicious forks. Look for:
      • Unpinned actions (e.g., uses: actions/checkout@v3 instead of uses: actions/checkout@sha256:...).
      • Forked repositories (e.g., uses: evil-org/trivy-action@main).
    • Example of a malicious workflow snippet:
      - name: Run Trivy vulnerability scanner
        uses: aquasecurity/trivy-action@v0.46.1  # Hijacked tag!
        with:
          image-ref: 'my-app:latest'
      
  3. Check for Hardcoded Secrets

    • Never store secrets in workflow files or environment variables. Use GitHub’s secret scanning to detect exposed credentials.

Tools to Automate Workflow Audits

ToolPurposeHow to Use
GitHub CodeQLDetect hardcoded secrets, suspicious dependenciesRun codeql analyze on your .github/workflows/ directory
TrivyScan workflows for vulnerabilities and secretstrivy fs --security-checks vuln,secret .github/workflows/
CheckovPolicy-as-code for CI/CD securitycheckov -d .github/workflows/
SemgrepCustom rule-based scanningsemgrep scan --config=p/ci

Key Red Flags in Workflows

Safe:

- name: Checkout code
  uses: actions/checkout@sha256:abc123...  # Pinned to a specific commit

Risky:

- name: Checkout code
  uses: actions/checkout@v3  # Unpinned, vulnerable to tag hijacking

Safe:

permissions:
  contents: read  # Least privilege

Risky:

permissions: write-all  # Overly permissive

Step 2: Rotate Exposed Secrets and Revoke Compromised Tokens

Close-up image of ethernet cables plugged into a network switch, showcasing IT infrastructure. Photo by Brett Sayles on Pexels

If your workflows were affected by the Trivy breach, assume your secrets are compromised. Even if you weren’t directly impacted, regular secret rotation is a critical security practice.

How to Identify Leaked Secrets

  1. GitHub Secret Scanning

    • GitHub automatically scans repositories for exposed credentials (e.g., AWS keys, Slack tokens). Check Security > Secret scanning in your repo settings.
  2. CI/CD Logs

    • Review logs for unauthorized access:
      • GitHub Audit Log: Filter for workflow_run events.
      • AWS CloudTrail: Look for unusual API calls.
      • GitLab/GCP/Azure Logs: Check for anomalous activity.
  3. Third-Party Integrations

    • If Trivy was used to scan Docker images, attackers may have accessed:
      • Container registry credentials (Docker Hub, GitHub Container Registry).
      • Cloud provider keys (AWS, GCP, Azure).

Step-by-Step Secret Rotation

  1. Revoke All GitHub Tokens

    • Personal Access Tokens (PATs): Delete and regenerate.
    • GitHub Actions Tokens: Automatically expire after each run, but revoke any long-lived tokens.
    • Deploy Keys: Rotate SSH keys used for deployments.
  2. Rotate Cloud Provider Keys

    • AWS: Use aws iam create-access-key to generate new keys.
    • GCP: Rotate service account keys via gcloud iam service-accounts keys rotate.
    • Azure: Regenerate keys in the Azure Portal.
  3. Update Third-Party Integrations

    • Slack, Jira, Datadog: Generate new API keys and update webhooks.
    • CI/CD Tools: Rotate tokens for Jenkins, CircleCI, or GitLab CI.
  4. Use Temporary Credentials

    • AWS STS: Generate short-lived credentials with AssumeRole.
    • HashiCorp Vault: Use dynamic secrets instead of static keys.

Best Practices for Secret Management

  • Never hardcode secrets in workflows or environment variables.
  • Use GitHub Environments to restrict secret access (e.g., production vs. staging).
  • Enable secret masking in GitHub Actions to prevent accidental leaks.
  • Use a secrets manager (AWS Secrets Manager, GCP Secret Manager, Azure Key Vault).

Step 3: Implement Least-Privilege Access in CI/CD Pipelines

The Trivy breach was exacerbated by overly permissive workflows. A single compromised action could push malicious code, delete repositories, or exfiltrate secrets—all because of excessive permissions.

Why Least Privilege Matters

  • 60% of CI/CD breaches involve excessive permissions (Palo Alto Networks 2025).
  • GitHub Actions tokens are powerful by default—they can:
    • Push code (contents: write).
    • Manage packages (packages: write).
    • Deploy to cloud providers (id-token: write).

How to Restrict GitHub Actions Permissions

  1. Set permissions: at the Workflow Level

    • Instead of granting write-all, specify only what’s needed:
      permissions:
        contents: read      # Only read repo contents
        packages: write     # Only push to GitHub Container Registry
        id-token: write     # Required for OIDC
      
  2. Use Fine-Grained Personal Access Tokens (PATs)

    • Avoid using admin tokens for CI/CD. Instead, create scoped PATs with minimal permissions.
  3. Restrict Workflow Runs to Specific Branches

    • Use on: push: branches: [main] to limit workflow execution.

Tools to Enforce Least Privilege

ToolPurposeExample
GitHub permissionsRestrict workflow accesspermissions: contents: read
Open Policy Agent (OPA)Custom CI/CD access rulesdeny[msg] { input.permissions == "write-all" }
AWS IAM Access AnalyzerAudit cloud permissionsaws accessanalyzer list-findings

Step 4: Replace Static Secrets with OpenID Connect (OIDC)

Detailed view of XML coding on a computer screen, showcasing software development. Photo by Markus Winkler on Pexels

The most secure way to eliminate static secrets in CI/CD is OpenID Connect (OIDC). Unlike long-lived API keys, OIDC tokens are short-lived, scoped, and automatically rotated.

Why OIDC is More Secure Than Static Secrets

  • No long-lived credentials = no secret rotation needed.
  • Short-lived tokens (e.g., AWS OIDC tokens expire in 1 hour).
  • Supported by major cloud providers: AWS, GCP, Azure, HashiCorp Vault.

How to Set Up OIDC in GitHub Actions

  1. Configure an OIDC Provider

    • AWS: Create an IAM OIDC Identity Provider.
      aws iam create-open-id-connect-provider \
        --url https://token.actions.githubusercontent.com \
        --client-id-list sts.amazonaws.com \
        --thumbprint-list <THUMBPRINT>
      
    • GCP: Configure Workload Identity Federation.
    • Azure: Set up Federated Identity Credentials.
  2. Add id-token: write to Workflow Permissions

    permissions:
      id-token: write  # Required for OIDC
    
  3. Use OIDC to Authenticate with Cloud Providers

    • AWS Example:
      - name: Configure AWS Credentials
        uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: arn:aws:iam::123456789012:role/GitHubOIDCRole
          aws-region: us-east-1
      
    • GCP Example:
      - name: Authenticate to Google Cloud
        uses: google-github-actions/auth@v1
        with:
          workload_identity_provider: projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider
          service_account: my-service-account@my-project.iam.gserviceaccount.com
      

Benefits of OIDC in CI/CD

FeatureStatic SecretsOIDC
LifespanLong-lived (months/years)Short-lived (minutes/hours)
RotationManualAutomatic
ScopeBroad permissionsFine-grained roles
SecurityHigh risk if leakedLow risk (expires quickly)

Key Takeaways: How to Secure Your CI/CD Pipelines After the Trivy Breach

The Trivy GitHub Actions breach was a wake-up call for CI/CD security. Here’s what you need to do right now to protect your pipelines:

  • Audit your workflows for compromised actions, unpinned dependencies, and hardcoded secrets.
  • Rotate all exposed secrets—assume they’re compromised if you used affected Trivy versions.
  • Enforce least-privilege access in GitHub Actions with permissions: and scoped tokens.
  • Replace static secrets with OIDC to eliminate long-lived credentials.
  • Monitor for suspicious activity using GitHub Audit Logs, AWS CloudTrail, and secret scanning.

Final Thoughts

Supply chain attacks like the Trivy breach are becoming more common650% increase in 2025 (Sonatype). The good news? You can prevent them with the right tools and practices.

If you’re looking for an extra layer of security, GhostShield VPN can help protect your CI/CD infrastructure by encrypting traffic between your runners and cloud providers, ensuring that even if secrets are exposed, attackers can’t intercept them.

Stay vigilant, stay secure, and harden your pipelines before the next breach happens.

Related Topics

secure CI/CD pipelineTrivy GitHub Actions breach 2026protect CI/CD secretsGitHub Actions securityprevent supply chain attacks in CI/CD

Keep Reading

Protect Your Privacy Today

GhostShield VPN uses AI-powered threat detection and military-grade WireGuard encryption to keep you safe.

Download Free
    Harden CI/CD Pipelines After Trivy GitHub Actions Breach: Step-by-Step Guide | GhostShield Blog | GhostShield VPN