Application Security

Software Supply-Chain Security: Dependencies, Build Systems and CI/CD

Over the holidays, a dependency-confusion attack hit PyTorch's nightly builds, and in January CircleCI told every customer to rotate their secrets. Supply-chain security now has a mature set of frameworks and tools. This article brings them together into a practical programme covering dependencies, build integrity and CI/CD.

By EthicalHat Research · · 3 min read
Infographic: A software supply-chain security programme

Two incidents in the last six weeks have kept software supply-chain security in the headlines.

  • PyTorch (late December 2022): a malicious package named torchtriton was uploaded to the public PyPI index. Because PyTorch's nightly builds were installed with an extra index URL that also consulted PyPI, users who installed nightly builds between 25 and 30 December received the malicious version, which collected system information and files. It was a textbook dependency confusion attack.
  • CircleCI (4 January 2023): the CI/CD provider announced a security incident and urged all customers to rotate every secret stored in the platform. It later explained that malware on an engineer's laptop had stolen a session token, bypassing multi-factor authentication, which gave the attacker access to production systems holding customer secrets.

The good news is that the industry's response has matured. There are now established frameworks and tools for most parts of the problem. Here is how to assemble them into a programme.

Layer 1: source

  • Protect main branches: required reviews, status checks, no direct pushes.
  • Enforce SSO and MFA for the source control platform, and review admin access regularly.
  • Require signed commits for sensitive repositories.
  • Use code owners for critical paths, including CI configuration.

Layer 2: dependencies

  • Pin and lock every dependency, with hashes where supported.
  • Use a single, controlled package source: an internal proxy that serves internal packages and approved public ones. Avoid configurations such as pip's --extra-index-url, which caused the PyTorch incident.
  • Claim your namespaces on public registries (npm scopes, PyPI prefixes) to prevent confusion attacks.
  • Scan continuously with software composition analysis, and generate SBOMs for releases.
  • Assess new dependencies using signals such as OpenSSF Scorecard (maintenance, branch protection, code review, signed releases).

Layer 3: CI/CD identity and secrets

The CircleCI incident shows what attackers want from CI platforms: stored secrets. The best defence is to store fewer of them.

Workload identity federation (OIDC) lets pipelines authenticate to cloud providers with short-lived tokens instead of stored access keys. GitHub Actions, GitLab CI and CircleCI all support issuing OIDC tokens that AWS, Azure and Google Cloud can trust:

yaml
# GitHub Actions: deploy to AWS with no stored credentials
permissions:
  id-token: write
  contents: read
jobs:
  deploy:
    runs-on: ubuntu-latest
    environment: production        # requires approval, restricted to main
    steps:
      - uses: actions/checkout@v3
      - uses: aws-actions/configure-aws-credentials@v1
        with:
          role-to-assume: arn:aws:iam::123456789012:role/gha-deploy-orders
          aws-region: eu-west-1
      - run: ./deploy.sh

The cloud role's trust policy should restrict which repository, branch and environment may assume it. Credentials expire when the job ends.

For secrets that must remain, scope them to environments and protected branches, and keep an inventory so emergency rotation is fast.

Layer 4: build integrity

SLSA (Supply-chain Levels for Software Artifacts), an OpenSSF framework, describes increasing levels of build integrity: from documenting the build process, through builds on a hosted service that generates provenance, to hardened, isolated builds whose provenance cannot be forged. A version 1.0 specification is being finalised. SLSA is a useful roadmap even before you aim for a particular level:

  • build on hosted, ephemeral runners, not long-lived shared servers,
  • generate provenance: a signed record of what source, builder and parameters produced an artefact, and
  • restrict who can change build definitions.

Layer 5: delivery

Sigstore, whose public-good services became generally available last October, makes signing practical: cosign can sign container images and other artefacts, including "keyless" signing tied to CI identity through OIDC.

bash
# Keyless signing in CI (identity comes from the CI provider's OIDC token)
COSIGN_EXPERIMENTAL=1 cosign sign registry.example.com/orders-api@sha256:1f0c...

# Verify at deploy time: signed by our pipeline, for this repository
COSIGN_EXPERIMENTAL=1 cosign verify \
  --certificate-identity-regexp 'https://github.com/example/orders-api/.github/workflows/release.yml@refs/heads/main' \
  registry.example.com/orders-api@sha256:1f0c...

Admission controllers in Kubernetes can then refuse to run anything unsigned or signed by the wrong identity.

flowchart LR
  S[Source<br/>protected, reviewed] --> B[Hosted, ephemeral build<br/>pinned dependencies]
  B --> P[Provenance + SBOM]
  B --> Sig[Signed artefact]
  P --> Reg[(Registry)]
  Sig --> Reg
  Reg --> AC{Admission control<br/>verify signature,<br/>provenance, policy}
  AC -->|pass| Prod[Production]
  AC -->|fail| Block[Blocked]

Layer 6: developer endpoints

CircleCI's breach began with malware on a laptop. Developer machines hold source code, session tokens and often credentials. Endpoint protection, hardware-backed authentication, short session lifetimes for sensitive platforms and separation between daily browsing and administrative access all reduce that risk.

Measuring progress

Three questions summarise supply-chain maturity:

  1. What's in it? Can we list every component of any release? (SBOMs, lock files)
  2. Who built it? Can we prove which pipeline built it from which source? (Provenance, signing)
  3. Can we trust it? Can we stop untrusted artefacts from running, and rotate every secret quickly? (Verification, federated identity, inventories)

The bottom line

The PyTorch and CircleCI incidents hit two different links in the chain: dependency resolution and CI secrets. Both have well-understood defences today: controlled package sources, federated short-lived credentials, build provenance and signature verification. Organisations that assemble them into a programme, layer by layer, make themselves far harder targets.

Our application security testing and secure code review services include supply-chain and CI/CD reviews, mapped to SLSA and OpenSSF guidance.

EthicalHat Research

The EthicalHat research team: penetration testers, SOC analysts and engineers writing about security, software engineering and AI.

Want an expert opinion on your own systems?

Email info@ethicalhat.com or call +1-844-838-4422. Our security engineers are happy to talk it through.