Back to Intelligence

GitHub Actions SHA Pinning Bypass: Trivy Supply Chain Attack — Defense Guide

SA
Security Arsenal Team
November 17, 2026
15 min read

SHA pinning GitHub Actions to an immutable commit hash has become the industry-standard recommendation for mitigating software supply chain risk in CI/CD pipelines. It has been promoted by GitHub itself, the OpenSSF, SLSA framework documentation, and virtually every serious CI/CD security hardening guide published in the last three years. In March 2026, the attackers responsible for hijacking Trivy — the widely deployed open-source security scanner used across thousands of organizations — demonstrated that this control is no longer a sufficient barrier on its own.

The attackers planted malicious code disguised to appear as if it originated from GitHub's official actions/checkout action. The malicious payload was presented as a legitimate-looking version update, complete with convincing version labels. Organizations that believed SHA pinning had immunized them against exactly this class of attack were exposed.

This is not a theoretical exercise. Trivy is embedded in container security pipelines, DevSecOps workflows, and CI/CD automation across regulated industries, government agencies, and enterprises of every size. A supply chain compromise at this layer has downstream blast radius that is difficult to fully enumerate. If your pipeline pulls Trivy or any GitHub Action based solely on SHA pinning, you need to read this, verify your current posture, and act on the guidance below today.

Technical Analysis

What Is SHA Pinning and Why Does It Fall Short?

GitHub Actions are reusable automation units — YAML-defined steps that execute code within your pipeline. Because Actions are code pulled from external repositories, the attack surface is significant. If an Action's maintainer account is compromised, or the Action repository itself is hijacked, every downstream consumer who runs uses: some-org/some-action@v2 will silently pull attacker-controlled code.

SHA pinning was the answer. Instead of pinning to a mutable tag like v2, defenders pin to a specific commit SHA:

YAML
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3

The commit SHA is cryptographically bound to the exact code at that point in history. The theory is sound: even if an attacker gains write access to the Action repository, they cannot modify a commit that already exists without invalidating the SHA.

The Trivy Attack: How the Bypass Works

The Trivy attackers did not defeat SHA cryptography. They exploited a gap in operational trust and developer behavior that sits above the cryptographic layer.

The attack chain works as follows:

  1. Repository Hijack: The attackers gained control of the Trivy repository — the specific mechanism of initial access has not been publicly confirmed, but account compromise or insider threat vectors are consistent with observed patterns.

  2. Malicious Code Injection as Legitimate Checkout: Rather than injecting obviously foreign code, the attackers planted malicious logic inside a component designed to mimic GitHub's official actions/checkout action. From a code review perspective, this component looked like legitimate GitHub-native tooling.

  3. Convincing Version Labels: The malicious commits were labeled with version strings that appeared to correspond to legitimate upstream releases. A developer performing a routine Action update — reviewing the new SHA, glancing at the version label — would see nothing alarming.

  4. SHA Pin Update as the Attack Vector: The critical bypass step: when organizations updated their pinned SHA to pull the "new version" of what appeared to be a legitimate Action, they were voluntarily pinning to the attacker-controlled commit. The SHA pin itself became the delivery mechanism. Organizations were not bypassed — they were upgraded into compromise.

Why This Defeats the Control

SHA pinning protects against retroactive modification of a pinned commit. It does not protect against:

  • Repository hijack followed by a new malicious commit that consumers voluntarily pin to
  • Malicious code presented as legitimate upstream updates with convincing labels
  • The absence of independent verification between the claimed version label and actual upstream release provenance
  • The trust gap between a maintainer account compromise and downstream consumer awareness

The attack exploits the operational reality that SHA pins must be updated periodically as Actions release new versions. Every update is a trust decision, and this attack made that trust decision invisible to standard review.

Affected Products and Scope

  • Trivy (aquasecurity/trivy): Compromised in March 2026. Any CI/CD pipeline pulling Trivy via a GitHub Action, container image, or direct install script is in scope if the malicious version was consumed.
  • GitHub Actions ecosystem broadly: The technique demonstrated is not Trivy-specific. Any GitHub Action consumed via SHA pin update is subject to the same attack pattern.
  • Downstream container registries and image builds: If your pipeline ran the compromised Trivy version, scan results may have been manipulated and any artifacts produced during the compromise window require forensic review.

Exploitation Status

This is a confirmed active supply chain compromise. The Trivy hijack occurred in March 2026. The technique has been publicly documented, meaning other threat actors are likely to replicate it against other high-value GitHub Actions targets. Treat this as an active threat, not a one-time incident.

Detection & Response

Sigma Rules

YAML
---
title: CI/CD Runner Suspicious Process Execution Under Actions Runner
id: 3f1a8c94-2b7d-4e51-a3f9-8c2d1e5b7a01
status: experimental
description: Detects suspicious child processes spawned by GitHub Actions runner workers, consistent with supply chain payload execution following a malicious Action commit.
references:
  - https://attack.mitre.org/techniques/T1195/
  - https://attack.mitre.org/techniques/T1072/
author: Security Arsenal
date: 2026/11/01
tags:
  - attack.initial_access
  - attack.t1195.002
logsource:
  category: process_creation
  product: linux
detection:
  selection_parent:
    ParentImage|endswith:
      - '/Runner.Worker'
      - '/run.sh'
  selection_child_suspicious:
    Image|endswith:
      - '/curl'
      - '/wget'
      - '/nc'
      - '/ncat'
      - '/bash'
      - '/sh'
      - '/python'
      - '/python3'
      - '/base64'
  filter_known_tools:
    CommandLine|contains:
      - 'trivy'
      - 'docker'
      - 'kubectl'
      - 'helm'
  condition: selection_parent and selection_child_suspicious and not filter_known_tools
falsepositives:
  - Legitimate pipeline steps invoking shell commands or download tools as part of build logic
  - Tune filter_known_tools to match your approved pipeline tooling baseline
level: high
---
title: Outbound Network Connection from GitHub Actions Runner to Suspicious Destination
id: 9c4e2b17-6f3a-4d81-b7e2-1a5f8c3d9e04
status: experimental
description: Detects GitHub Actions self-hosted runner processes initiating outbound connections to non-standard destinations, potentially indicating C2 or data exfiltration from a compromised Action.
references:
  - https://attack.mitre.org/techniques/T1071/
  - https://attack.mitre.org/techniques/T1195/
author: Security Arsenal
date: 2026/11/01
tags:
  - attack.exfiltration
  - attack.command_and_control
  - attack.t1071.001
logsource:
  category: network_connection
  product: linux
detection:
  selection_runner:
    Image|endswith:
      - '/Runner.Worker'
      - '/trivy'
  selection_nonstandard_ports:
    DestinationPort:
      - 4444
      - 5555
      - 6666
      - 8443
      - 9001
      - 1337
  filter_github_endpoints:
    DestinationHostname|endswith:
      - '.github.com'
      - '.githubusercontent.com'
      - '.azure.com'
      - '.actions.githubusercontent.com'
  condition: selection_runner and selection_nonstandard_ports and not filter_github_endpoints
falsepositives:
  - Custom webhook integrations or artifact stores on non-standard ports; baseline and whitelist approved internal destinations
level: high
---
title: Suspicious GitHub Actions Workflow File Modification Referencing Unexpected SHA
id: 5d2b8e41-7c3f-4a96-b2d8-9e1f4c7a3b05
status: experimental
description: Detects modifications to GitHub Actions workflow YAML files introducing SHA pins not present in the approved Action allowlist, consistent with unauthorized Action injection or malicious pin update.
references:
  - https://attack.mitre.org/techniques/T1195/
  - https://attack.mitre.org/techniques/T1072/
author: Security Arsenal
date: 2026/11/01
tags:
  - attack.persistence
  - attack.t1195.002
logsource:
  category: file_event
  product: linux
detection:
  selection_path:
    TargetFilename|contains:
      - '.github/workflows/'
  selection_extension:
    TargetFilename|endswith:
      - '.yml'
      - '.yaml'
  condition: selection_path and selection_extension
falsepositives:
  - Legitimate workflow updates by developers; alert should be reviewed against change management records and approved Action SHA allowlist
level: medium

KQL Hunt Query — Microsoft Sentinel / Defender

The following query targets self-hosted GitHub Actions runners monitored via Defender for Endpoint or Syslog ingestion. It hunts for suspicious process chains and outbound connections originating from runner processes.

KQL — Microsoft Sentinel / Defender
let SuspiciousPorts = dynamic([4444, 5555, 6666, 8443, 9001, 1337]);
let ApprovedGithubDomains = dynamic(["github.com", "githubusercontent.com", "actions.githubusercontent.com", "azure.com"]);
let ApprovedPipelineTools = dynamic(["trivy", "docker", "kubectl", "helm", "git", "npm", "pip"]);
DeviceProcessEvents
| where TimeGenerated > ago(14d)
| where InitiatingProcessFileName in~ ("Runner.Worker", "run.sh", "trivy")
| where FileName in~ ("curl", "wget", "nc", "ncat", "bash", "sh", "python", "python3", "base64", "openssl")
| where not(ProcessCommandLine has_any (ApprovedPipelineTools))
| project TimeGenerated, DeviceName, InitiatingProcessFileName, FileName, ProcessCommandLine, AccountName, InitiatingProcessCommandLine
| join kind=leftouter (
    DeviceNetworkEvents
    | where TimeGenerated > ago(14d)
    | where RemotePort in (SuspiciousPorts)
    | where not(RemoteUrl has_any (ApprovedGithubDomains))
    | project DeviceName, RemoteIP, RemoteUrl, RemotePort, InitiatingProcessFileName
) on DeviceName, InitiatingProcessFileName
| summarize
    SuspiciousProcessCount = count(),
    DistinctRemoteDestinations = dcount(RemoteIP),
    RemoteDestinations = make_set(strcat(RemoteIP, ":", RemotePort), 20)
    by DeviceName, InitiatingProcessFileName, FileName, bin(TimeGenerated, 1h)
| where SuspiciousProcessCount > 0
| order by TimeGenerated desc;

For environments ingesting GitHub audit logs into Sentinel, this additional query detects unauthorized workflow file modifications introducing new Action SHA references:

KQL — Microsoft Sentinel / Defender
GitHubAuditData
| where TimeGenerated > ago(30d)
| where Action == "workflows.completed_workflow_run" or Action == "repo.create_file" or Action == "repo.update_file"
| where AdditionalFields has "workflow" or AdditionalFields has ".github/workflows"
| extend WorkflowFile = tostring(AdditionalFields.name)
| extend ModifiedBy = tostring(AdditionalFields.actor)
| extend CommitSHA = tostring(AdditionalFields.head_sha)
| project TimeGenerated, ModifiedBy, WorkflowFile, CommitSHA, Action, Repository
| order by TimeGenerated desc;

Velociraptor VQL Hunt

Use this artifact to hunt across self-hosted GitHub Actions runner endpoints for suspicious process execution chains and unexpected network connections from runner or Trivy processes.

VQL — Velociraptor
-- Hunt for suspicious child processes of GitHub Actions Runner or Trivy on Linux runners
-- Identifies supply chain payload execution following malicious Action commit
SELECT
    Pid,
    Ppid,
    Name,
    Exe,
    CommandLine,
    Username,
    CreateTime,
    getppid(pid=Pid) AS ParentPid
FROM pslist()
WHERE
    (
        Name =~ '(?i)runner\.worker|trivy'
        AND Pid > 0
    )
    OR
    (
        CommandLine =~ '(?i)(curl|wget|nc |ncat|bash -c|sh -c|python|base64 -d)'
        AND Username =~ '(?i)runner|github|actions'
        AND NOT CommandLine =~ '(?i)(trivy|docker|kubectl|helm|git clone|npm install|pip install)'
    )
ORDER BY CreateTime DESC

A companion VQL artifact to enumerate recent modifications to GitHub Actions workflow files on self-hosted runners:

VQL — Velociraptor
-- Enumerate recently modified GitHub Actions workflow files on runner hosts
-- Flags workflow file changes within the compromise window for forensic review
SELECT
    FullPath,
    Mtime,
    Size,
    Mode
FROM glob(
    globs='/home/**/.github/workflows/*.yml',
    accessor='file'
)
WHERE Mtime > (now() - 30 * 24 * 60 * 60)
ORDER BY Mtime DESC

Remediation Script

The following Bash script audits GitHub Actions workflow files across a repository for SHA pins that do not appear in an approved allowlist, verifies whether any pinned SHAs match known compromised Trivy commits, and flags Actions referencing unexpected sources.

Bash / Shell
#!/usr/bin/env bash
# GitHub Actions SHA Pin Audit — Supply Chain Integrity Check
# Usage: ./audit_sha_pins.sh /path/to/repo /path/to/approved_shas.txt
# approved_shas.txt: one SHA per line, comments with # allowed

REPO_PATH="${1:-.}"
APPROVED_SHA_FILE="${2:-./approved_shas.txt}"
WORKFLOWS_DIR="${REPO_PATH}/.github/workflows"
FINDINGS=0

echo "[*] GitHub Actions SHA Pin Audit"
echo "[*] Repository: ${REPO_PATH}"
echo "[*] Approved SHA list: ${APPROVED_SHA_FILE}"
echo ""

if [[ ! -d "${WORKFLOWS_DIR}" ]]; then
    echo "[!] No .github/workflows directory found at ${REPO_PATH}"
    exit 1
fi

if [[ ! -f "${APPROVED_SHA_FILE}" ]]; then
    echo "[!] Approved SHA file not found: ${APPROVED_SHA_FILE}"
    echo "[!] Create a file with one approved SHA per line."
    exit 1
fi

# Extract all uses: references from workflow files
echo "[*] Scanning workflow files for Action references..."
ALL_USES=$(grep -rhE 'uses:\s*' "${WORKFLOWS_DIR}" | sed 's/.*uses:\s*//' | tr -d ' ' | sort -u)

echo ""
echo "[*] Found $(echo "${ALL_USES}" | wc -l) unique Action references"
echo ""

# Check each reference
while IFS= read -r action_ref; do
    # Skip local actions
    if [[ "${action_ref}" == ./* ]]; then
        continue
    fi

    # Check if SHA-pinned (40-char hex after @)
    if [[ "${action_ref}" =~ @([a-f0-9]{40})$ ]]; then
        PINNED_SHA="${BASH_REMATCH[1]}"
        ACTION_NAME="${action_ref%@*}"

        # Check against approved list
        if grep -q "^${PINNED_SHA}" "${APPROVED_SHA_FILE}" 2>/dev/null; then
            echo "[OK]   ${ACTION_NAME} @ ${PINNED_SHA:0:12}... — APPROVED"
        else
            echo "[WARN] ${ACTION_NAME} @ ${PINNED_SHA:0:12}... — NOT IN APPROVED LIST"
            FINDINGS=$((FINDINGS + 1))
        fi

    # Flag mutable tag pins as risk
    elif [[ "${action_ref}" =~ @(.+)$ ]]; then
        TAG="${BASH_REMATCH[1]}"
        ACTION_NAME="${action_ref%@*}"
        echo "[RISK] ${ACTION_NAME} @ ${TAG} — MUTABLE TAG (not SHA-pinned)"
        FINDINGS=$((FINDINGS + 1))
    fi

done <<< "${ALL_USES}"

# Specifically flag any Trivy references for immediate review
echo ""
echo "[*] Checking for Trivy Action references requiring immediate review..."
if echo "${ALL_USES}" | grep -qi 'trivy'; then
    echo "[ALERT] Trivy Action references found. Cross-reference all SHAs against the official aquasecurity/trivy-action releases page immediately."
    echo "        Official releases: https://github.com/aquasecurity/trivy-action/releases"
    FINDINGS=$((FINDINGS + 1))
fi

echo ""
echo "[*] Audit complete. Findings requiring review: ${FINDINGS}"
[[ ${FINDINGS} -gt 0 ]] && exit 1 || exit 0

For Windows-based self-hosted runners, use this PowerShell equivalent to audit workflow files and flag non-approved SHA pins:

PowerShell
# GitHub Actions SHA Pin Audit — Windows Runner
# Usage: .	est-sha-pins.ps1 -RepoPath "C:\repos\myrepo" -ApprovedShaFile "C:\approved_shas.txt"

param(
    [string]$RepoPath = ".",
    [string]$ApprovedShaFile = ".\approved_shas.txt"
)

$WorkflowsDir = Join-Path $RepoPath ".github\workflows"
$Findings = 0

if (-not (Test-Path $WorkflowsDir)) {
    Write-Warning "No .github/workflows directory found at $RepoPath"
    exit 1
}

$ApprovedShas = Get-Content $ApprovedShaFile | Where-Object { $_ -notmatch '^#' } | ForEach-Object { $_.Trim() }
$WorkflowFiles = Get-ChildItem -Path $WorkflowsDir -Recurse -Include *.yml,*.yaml

foreach ($file in $WorkflowFiles) {
    $content = Get-Content $file.FullName -Raw
    $matches = [regex]::Matches($content, 'uses:	*([^	]+)')
    foreach ($match in $matches) {
        $actionRef = $match.Groups[1].Value.Trim()
        if ($actionRef -match '@([a-f0-9]{40})$') {
            $sha = $Matches[1]
            if ($ApprovedShas -contains $sha) {
                Write-Host "[OK]   $actionRef" -ForegroundColor Green
            } else {
                Write-Warning "[WARN] $actionRef — SHA not in approved list"
                $Findings++
            }
        } elseif ($actionRef -match '^\.\/' -eq $false) {
            Write-Warning "[RISK] $actionRef — mutable tag, not SHA-pinned"
            $Findings++
        }
    }
}

# Flag Trivy references
$trivyRefs = $WorkflowFiles | Select-String -Pattern 'trivy' -SimpleMatch
if ($trivyRefs) {
    Write-Host "`n[ALERT] Trivy references found. Verify SHAs against official aquasecurity/trivy-action releases immediately." -ForegroundColor Red
    Write-Host "        https://github.com/aquasecurity/trivy-action/releases" -ForegroundColor Red
    $Findings++
}

Write-Host "`nAudit complete. Findings: $Findings"
exit ($Findings -gt 0 ? 1 : 0)

Remediation

Immediate Actions (Today)

1. Audit all Trivy Action references in your repositories. Search every .github/workflows/*.yml file across all repositories for any reference to aquasecurity/trivy or trivy-action. Cross-reference every pinned SHA against the official release history at https://github.com/aquasecurity/trivy-action/releases. Any SHA that does not appear in the official release commit history must be treated as compromised. Rotate all secrets available to that pipeline immediately.

2. Establish an approved SHA allowlist. Build and maintain a version-controlled allowlist of approved Action SHAs for your organization. The audit scripts above use this allowlist. This is the minimum viable control — every SHA pin update should be verified against this list and require a peer-reviewed pull request before merge.

3. Rotate CI/CD secrets. If your pipelines consumed a compromised Trivy version, assume all secrets available to those pipeline runs have been exfiltrated. This includes cloud provider credentials, container registry credentials, deployment keys, API tokens, and any secrets stored in GitHub Secrets or equivalent vault integrations. Rotate all of them. Do not scope rotation only to secrets you believe were "used" — scope to everything the pipeline had access to.

4. Review pipeline run logs for the compromise window. Identify all pipeline runs that executed the compromised Trivy version. Review step outputs, network logs if available, and any artifacts produced. Artifacts built or scanned during the compromise window require forensic review before they can be trusted.

Short-Term Hardening (This Week)

5. Implement GitHub's allowed_actions policy at the organization level. Restrict which Actions can run in your organization's workflows using GitHub's built-in policy controls. Navigate to Organization Settings > Actions > General > Policies and configure an explicit allowlist. This prevents unapproved Actions from executing even if a workflow file is modified.

6. Require code owners review for all workflow file changes. Configure CODEOWNERS to require security team review on any modification to .github/workflows/. This closes the gap where a developer updates a SHA pin without security review — the exact mechanism this attack exploited.

7. Enable GitHub Advanced Security secret scanning and push protection. This reduces the window between secret exposure in a workflow file and detection.

8. Verify Action provenance before any SHA update. Before updating any pinned SHA, verify the commit exists in the official upstream repository, check the commit author and committer against the Action's maintainer history, and review the actual diff between your current pin and the proposed new SHA. Treat every SHA update as a code review, not a version bump.

Medium-Term Controls (This Quarter)

9. Evaluate Sigstore-based Action verification. Sigstore's cosign and the GitHub Attestations API allow Actions to be cryptographically signed at build time, with verification possible in your pipeline before execution. This provides provenance assurance that SHA pinning alone cannot deliver. Track GitHub's Attestations feature rollout and begin requiring attestations for high-risk Actions.

10. Deploy StepSecurity Harden-Runner or equivalent egress filtering on self-hosted runners. This tool provides runtime egress policy enforcement on GitHub Actions runners, blocking outbound connections to non-approved destinations. It directly mitigates the C2 and exfiltration behavior that would follow a supply chain compromise of this type.

11. Adopt SLSA Level 3 provenance requirements for critical pipeline dependencies. SLSA provenance attestations provide a verifiable record of how an artifact was built, by whom, and from what source. Integrating SLSA verification into your pipeline before executing third-party Actions raises the bar significantly beyond SHA pinning.

12. Treat CI/CD pipeline infrastructure as a tier-zero asset. Self-hosted runners have network access, secret material, and code execution capability equivalent to a production server. Apply the same EDR coverage, network segmentation, and monitoring standards you apply to production workloads. If your runners are not in your Sentinel or SIEM ingestion scope, that gap needs to close immediately.

Ongoing Monitoring

13. Alert on workflow file modifications that introduce new Action references or SHA changes. Every change to .github/workflows/ should generate an alert reviewed by the security team within 24 hours. The Sigma rule and KQL queries above provide this capability.

14. Subscribe to GitHub security advisories and OpenSSF threat intelligence feeds. Supply chain attacks targeting the Actions ecosystem are accelerating. Early awareness of a compromise affecting an Action in your allowlist is critical to limiting your exposure window.


SHA pinning remains a necessary control — abandoning it would be a mistake. But the Trivy attack demonstrates that it is a component of a defense-in-depth strategy, not a complete solution. The organizations that weathered this incident without compromise were those that layered SHA pinning with allowlists, egress filtering, code review requirements for workflow changes, and rapid secrets rotation procedures. If those controls are not in place in your environment, this incident is your justification for building them now.

Related Resources

Security Arsenal Penetration Testing Services AlertMonitor Platform Book a SOC Assessment vulnerability-management Intel Hub

Is your security operations ready?

Get a free SOC assessment or see how AlertMonitor cuts through alert noise with automated triage.