Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

Hardening the build environment: securing runners and pipelines

By updated

Improve this page

A CI/CD pipeline often has privileged access to sensitive resources: source code, registries, deployment identities, application secrets or temporary cloud access. It is the perfect target for a supply chain attack. And yet it is often the last place people think of securing.

Hardening the build environment means reducing the attack surface of your CI/CD pipelines: runners, secrets, network, cache and build process. It is a practical prerequisite for progressing towards SLSA, especially once you aim for a controlled build platform and, even more, for level 3 hardened builds.

What you will learn

  • The attack vectors against build environments
  • The defensive architecture: ephemeral runners, isolation, egress control
  • Secret management: OIDC and short-lived credentials
  • Step-by-step hardening of GitHub Actions and GitLab CI
  • SOCLE anchoring: this lesson produces the evidence for SOCLE-ORC-EPH-1 (in French), a runner that runs a single job and is then destroyed, and for the runner egress and identity requirements

Prerequisites

Why secure the build environment?

A compromised workstation affects one developer; a compromised CI/CD runner affects everything the pipeline signs, publishes and deploys. The three subsections below lay out the reasoning in this order: what powers the pipeline really holds, through which doors an attacker gets in, and what this has already produced in real conditions. Without that framing, the countermeasures look like an arbitrary checklist.

The pipeline: a target of choice

The build environment is a critical asset because it:

FeatureAssociated risk
Has access to production secretsCredential exfiltration
Can modify the code (merge, tag)Backdoor injection
Signs artifactsSigning compromised artifacts
Publishes to registriesMalware distribution
Runs third-party code (actions, packages)Malicious code execution

Each row adds up with the others: a pipeline brings together in a single execution context what an organisation usually splits across several teams and several accounts. The consequence is that compromising a single job often gives everything, without needing any further pivot.

The attack surface of a pipeline

The diagram below lists the six zones an attacker can enter through. Read it from left to right: each arrow is a trust relationship that nothing checks by default, from the repository to the runner, from the runner to the registry. Two zones are often overlooked: the cache (reused across runs with no integrity check) and network egress, left open by default on many runners.

Attack surface of a CI/CD pipeline: source code and dependencies, through actions and jobs, feed the runner, which produces the artifacts and talks to the network; each zone has its risks, from the compromised repository to the poisoned cache and open egress.Source code: compromised repo, malicious PR, modified workflowDependencies: npm, pip, Maven, base images, cacheRunner: persistent VM, exposed secrets, open networkActions and jobs: third-party actions, plugins, broad permissionsArtifacts: signed image, registry, poisoned cacheNetwork: open egress, command channel, exfiltration
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %

Examples of real attacks

These five incidents are publicly documented. Look above all at the Vector column: none relies on a flaw in the CI/CD product itself, all exploit trust granted to a script, a maintainer or a third-party action. That is the key point for what follows: hardening is about the build's inputs, not about hardening the CI product. More recent GitHub Actions cases are analysed in Supply chain attacks on GitHub Actions.

AttackVectorImpact
Codecov (2021)Bash Uploader script tampered with at the source, then run in customers' CIExfiltration of CI secrets to the attacker
Event-stream (2018)Compromised maintainer, malicious codeBitcoin theft through an npm dependency
SolarWinds (2020)Compromise of the build systemBackdoor installed by nearly 18,000 customers
tj-actions (2025)Compromised GitHub actionExfiltration of secrets
xz-utils (2024)Modified build scriptsSSH backdoor in the binaries

The Codecov case reads in two steps. A flaw in how Codecov built its Docker image let an attacker tamper with its Bash Uploader script at the source. That script, downloaded then executed (curl | bash) in customers' CI, sent their environment variables to the attacker. The customers' pipelines were not attacked: they ran, with no integrity check, a tool fetched at run time, which is exactly the thesis of this page.

Defensive architecture

The measures that follow are independent: each one can be put in place on its own and brings a measurable gain, without waiting for the six others to be in production. That is what makes CI/CD hardening affordable, unlike an architecture overhaul. They do complement each other, though: an ephemeral runner without reduced permissions still lets a single job exfiltrate a deployment token.

The 7 hardening pillars

The diagram sums up the seven measures and their reading order. The first three (ephemerality, isolation, least privilege) limit what an attacker gets if they run code; the next three (egress, short secrets, verification) limit what they can do with it; the seventh (input immutability) reduces the chance they run anything at all. None is enough on its own.

The seven hardening pillars in three families: limit what executed code gets (ephemerality, isolation, least privilege), limit what it can do with it (egress, short secrets, verification), reduce the chance of execution (input immutability).Reduce the chance ofexecution7. Immutability: actions by SHA, images by digest, lockfilesLimit what it can do with it4. Egress: allow-list of destinations5. Short secrets: OIDC, ephemeral tokens6. Verification: review of workflows and inputsLimit what executed code gets1. Ephemerality: runner destroyed after each job2. Isolation: no access between jobs3. Least privilege: minimal permissions
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %

Pillar 1: Ephemeral runners

Principle: each job runs on a clean machine, destroyed after execution.

The table compares the four modes you will meet, on the three axes that really decide the choice. Remember above all that the persistent runner row is the default of many self-hosted installations: it is the mode where a malicious job leaves behind credentials, a modified binary or a poisoned cache for the next job.

ModeSecurityPerformanceCost
Persistent runnerLowFastLow
Ephemeral VM runnerVery good baseline isolationMediumMedium
Ephemeral container runnerGood level possible, depending on configurationFastLow
GitHub-hostedHighMediumHigh

Why it is crucial:

  • No persistence of an attacker between jobs
  • No leftover credentials on the machine
  • No persistent malware installed by a previous job

With Actions Runner Controller (ARC), self-hosted runners run on Kubernetes as runner scale sets: each runner runs a single job, then its pod is deleted. The old RunnerDeployment mode of the community summerwind project is abandoned. Installation goes through two Helm charts published by GitHub, the controller then the scale set:

Terminal window
# ARC controller
helm install arc --namespace arc-systems --create-namespace --version 0.15.0 \
oci://ghcr.io/actions/actions-runner-controller-charts/gha-runner-scale-set-controller
# Scale set: workflows target it with runs-on: arc-runner-set
helm install arc-runner-set --namespace arc-runners --create-namespace --version 0.15.0 \
--set githubConfigUrl="https://github.com/my-org/my-repo" \
--set githubConfigSecret=arc-github-app \
oci://ghcr.io/actions/actions-runner-controller-charts/gha-runner-scale-set

arc-github-app is a Kubernetes secret created beforehand with the credentials of a GitHub App: never a personal token in clear on the command line. These commands follow the quickstart of the ARC documentation, chart version 0.15.0; they were not replayed here, for lack of a dedicated cluster and GitHub App. How disposable runners work in full (the --ephemeral option, autoscaling) is covered in Ephemeral GitHub Actions runners.

Pillar 2: Isolation between jobs

Principle: a job must not be able to reach another job's resources.

There are two kinds of isolation to tell apart:

KindDescriptionMechanisms
Execution isolationTechnical separation (processes, network, filesystem)Ephemeral runners, network policies, dedicated containers or VMs
Logical separationAccess control to resources (secrets, deployments)Environments, permissions, approvals
.github/workflows/secure-build.yml
# No permission by default, each job reopens only what it needs
permissions: {}
jobs:
build:
runs-on: ubuntu-24.04
# Logical separation through an environment (dedicated secrets, approvals)
environment: production
# Minimal permissions per job
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# Readable here: repository, production-environment and (if shared with this repo) organization secrets
- name: Build
env:
API_KEY: ${{ secrets.PROD_API_KEY }}
run: make build

Pillar 3: Least privilege (minimal permissions)

Principle: each job only reaches the resources it strictly needs.

In practice, this plays out on a single token, the GITHUB_TOKEN, injected automatically into every job. Its rights by default depend on the repository and organisation settings, so they vary from one project to another and change over time. The only tenable position is to declare them explicitly in the workflow.

GitHub Actions: explicit permissions

The permissions: {} block at the top of a workflow removes all the rights of the GITHUB_TOKEN, contents: read included. Each job then declares what it needs, which makes the audit possible by reading the workflow file alone. Note the persist-credentials: false on actions/checkout: without it, the action writes the token into .git/config, where any later step can read it back, including a third-party build script.

# Remove default permissions
permissions: {}
jobs:
lint:
runs-on: ubuntu-24.04
permissions:
contents: read # Read the code only
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- run: npm run lint
deploy:
runs-on: ubuntu-24.04
needs: lint
permissions:
contents: read
id-token: write # For OIDC
packages: write # To publish
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Deploy
run: make deploy

GitHub Actions permission matrix

This matrix is a review aid: for each permission requested in a workflow, check that a job really justifies it. Two rows deserve particular attention, contents: write (which lets a job rewrite the repository, hence inject code into a future build) and id-token: write (which opens the door to the cloud if the trust policy on the provider side is too broad).

PermissionWhen to use itRisk if too broad
contents: readCode checkoutLets the job read the code (a risk if given to untrusted code)
contents: writePush, merge, tagsModifying the repository, tags, releases, code injection
packages: writePublishing images or packagesMalware distribution through the registry
id-token: writeOIDC to cloud providersCloud access if the provider-side trust is misconfigured
actions: writeWorkflow managementModifying or cancelling sensitive workflows
security-events: writeUploading scan resultsPotential hiding of vulnerabilities

Pillar 4: Egress control (outbound network)

Principle: limit the allowed network destinations to prevent exfiltration.

Why it is critical:

  • A compromised runner can send secrets to a command-and-control server
  • Attacks such as Codecov exfiltrate data over HTTP

Implementation with Harden-Runner (GitHub Actions)

Harden-Runner goes in as the first step of the job, before checkout: it must be active before any third-party code runs. Always start with egress-policy: audit, which blocks nothing but logs every destination contacted. Without that observation phase, blocking mode breaks the build at the first package mirror you had forgotten. The Harden-Runner guide covers installation and how to read the audit report.

jobs:
build:
runs-on: ubuntu-24.04
steps:
- name: Harden Runner
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
# Audit mode (recommended to start with)
egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- run: npm ci
- run: npm run build

After a few runs, the list of legitimate destinations is stable: switch to blocking mode by copying it into allowed-endpoints. Everything not listed is refused, DNS resolutions included.

- name: Harden Runner
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
egress-policy: block
allowed-endpoints: >
github.com:443
registry.npmjs.org:443
nodejs.org:443

Kubernetes network policies (self-hosted)

This example shows a port restriction (443 only), not a true allow-list of destinations:

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: runner-egress-port-restriction
spec:
podSelector:
matchLabels:
app: github-runner
policyTypes:
- Egress
egress:
# PORT restriction, not a destination restriction
- to:
- ipBlock:
cidr: 0.0.0.0/0
ports:
- port: 443
protocol: TCP
# This allows the whole Internet on 443, not an allow-list

Pillar 5: Short-lived secrets (OIDC)

Principle: replace static secrets with ephemeral tokens through OIDC.

A static secret stored in GitHub or GitLab stays valid until someone revokes it, sometimes long after a leak. OIDC removes the secret from the pipeline altogether: the job presents a verifiable identity and receives in exchange credentials that expire quickly.

The problem with static secrets

These four secrets turn up in almost every pipeline. What they share is being exfiltrable in one line (a misplaced echo, a verbose log, a malicious dependency) and staying exploitable long after the leak, with nothing to flag it.

Static secretRisk
AWS access keyValid indefinitely, exfiltrable
Docker Hub tokenLets you publish images
npm tokenLets you publish packages
KubeconfigFull access to the cluster

The solution: OIDC (OpenID Connect)

The exchange takes three steps. The key point is that nothing is stored on the pipeline side: the JWT token is minted on demand by the forge, it carries the workflow's identity (repository, branch, environment) and it is only worth something to the cloud provider that explicitly authorised it. The step-by-step per provider is in GitHub Actions OIDC: AWS, Azure, GCP.

  1. GitHub generates an OIDC token (JWT) carrying the workflow's identity.
  2. The cloud provider checks the token and issues temporary credentials.
  3. The credentials expire quickly, usually after a few minutes to a few hours.
jobs:
deploy:
runs-on: ubuntu-24.04
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Configure AWS credentials (OIDC)
uses: aws-actions/configure-aws-credentials@e6de054238d6b7531b4efff3b6587d9aade6a06c # v6.2.3
with:
role-to-assume: arn:aws:iam::123456789:role/github-actions
aws-region: eu-west-1
# No secret! The OIDC token is enough
- name: Deploy to S3
run: aws s3 sync ./dist s3://my-bucket

Pillar 6: Input verification

Principle: validate and restrict what can trigger and modify the pipeline.

A pull request's code is unapproved code, even when it comes from a colleague. Two questions decide the risk level: which event triggers the workflow, and which ref checkout really fetches.

Protections on pull requests

The workflow below refuses to run the job when the PR comes from a fork (head.repo.full_name differs from the repository), and checks out the base branch rather than the PR's content. Keep this pattern for sensitive workflows: for ordinary CI, testing the PR's code is precisely the point, but then without permissions or secrets.

.github/workflows/ci.yml
on:
pull_request:
# Fork PRs run without secrets by default; the `if:` below refuses them anyway
# Use pull_request_target with care
jobs:
build:
runs-on: ubuntu-24.04
# Refuse PRs coming from a fork: only the repository itself passes
if: github.event.pull_request.head.repo.full_name == github.repository
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# Check out the base, not the PR (for sensitive workflows)
ref: ${{ github.base_ref }}

Blocking changes to sensitive files

fetch-depth: 0 is essential here: without the full history, the git diff against origin/main fails for lack of a comparison base. The job stops with an error as soon as a PR touches a workflow, the Dockerfile or the Makefile, that is the files that decide what the CI runs.

.github/workflows/ci.yml
jobs:
check-files:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
fetch-depth: 0
- name: Check for sensitive file changes
run: |
SENSITIVE_FILES=".github/workflows/ Dockerfile Makefile"
CHANGED=$(git diff --name-only origin/main...HEAD)
for file in $SENSITIVE_FILES; do
if echo "$CHANGED" | grep -q "$file"; then
echo "::error::Modification of $file requires special approval"
exit 1
fi
done

Pillar 7: Input immutability

Principle: freeze the build's inputs to prevent silent changes.

A Git tag is mutable: v4 can be moved to another commit without anything changing in your repository. That is exactly the mechanism exploited in the 2025 tj-actions incident. The table lists the four families of inputs and the practice that freezes each one.

InputRisk if not frozenGood practice
GitHub actionsA mutable tag can be changedPin by SHA
Docker imageslatest or version tag can changePin by digest
DependenciesDynamic resolution can changeMandatory lockfiles
Downloaded scriptsContent can be changed at the source, as with CodecovForbid curl | bash

Always write the tag as a comment after the SHA: without it, nobody knows which version is running and updates stop happening.

# Actions pinned by SHA
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
# Images pinned by digest
FROM python:3.12-slim@sha256:dddfd7e07f9d15aeeca61529320492139d21cac7f0070c00609243e51e4e0016

The digest above is that of python:3.12-slim on 2 October 2026, read from the registry with docker buildx imagetools inspect python:3.12-slim. Read yours the same way rather than copying this one, and never with docker inspect, which reads the local copy of the image, possibly outdated: a digest designates one precise, frozen image, which is the whole point, but it also means it will never receive a fix again. Pinning by digest therefore requires deliberate refreshes, otherwise you freeze the vulnerabilities too.

A script distributed over HTTP has none of these guarantees. If a tool only installs through direct download, fetch the archive and the checksum file published by the vendor, verify, and only then extract:

Terminal window
curl -fsSLO https://example-vendor.tld/tool-1.2.3-linux-amd64.tar.gz
curl -fsSLO https://example-vendor.tld/tool-1.2.3-checksums.txt
sha256sum --check --ignore-missing tool-1.2.3-checksums.txt
tar -xzf tool-1.2.3-linux-amd64.tar.gz

The URLs above are examples of form: use those published by your tool's vendor. What matters is the order of operations: sha256sum --check must succeed before any line of the downloaded content is run or extracted.

Step-by-step hardening

The two checklists that follow turn the seven pillars into concrete actions, one per platform. The GitHub Actions list goes from the most cost-effective to the most expensive: its first three items are the most cost-effective and address the vectors seen in the incidents above; the GitLab one follows the logic of the settings, not a cost ranking. Work through them in order rather than in parallel, checking each step on a real pipeline before moving on.

GitHub Actions hardening checklist

Apply these seven items to an existing workflow, not to a demo file: doing it on code that runs is how you discover the implicit dependencies (a job that wrote a tag, an action that read the token from .git/config).

  1. Minimal permissions globally

    Switch everything off at workflow level with permissions: {}, then reopen job by job. A global contents: read looks harmless, but it gives access to the code to every job, including those running third-party dependencies.

    # At workflow level: no permission by default
    permissions: {}
    jobs:
    lint:
    permissions:
    contents: read
  2. Pin actions by SHA

    # ❌ Bad
    - uses: actions/checkout@v4
    # Good: commit SHA, version as a comment
    - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

    Automate with pinact or pin-github-action, and keep the commit SHA, never that of the annotated tag object. The Pinning actions by SHA lesson details the method.

  3. OIDC for every cloud deployment

    Replace static AWS, GCP or Azure secrets with OIDC.

  4. Harden-Runner for egress control

    - uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
    with:
    egress-policy: audit # then block
  5. Environments for sensitive secrets

    Configure environments with approval for production.

  6. Mandatory code review for workflows

    Add the .github/workflows/** files to CODEOWNERS.

  7. Regular permission audit

    Use StepSecurity Secure Repo to audit.

GitLab CI hardening checklist

GitLab splits the settings differently: a large part of the hardening does not live in .gitlab-ci.yml but in the project settings (protected variables, protected branches, approvals). The six items below say each time on which side the setting is made.

  1. Protected and masked variables (GitLab UI side)

    Protected and masked variables are configured in GitLab (Settings, CI/CD, Variables), not in the YAML:

    • Protected: only available on protected branches and tags
    • Masked: hidden in pipeline logs

    In .gitlab-ci.yml, you simply use the variable:

    deploy_prod:
    script:
    - echo "Deploying with key..."
    # The value goes through stdin, never through the command line
    - printf '%s' "$PROD_API_KEY" | deploy --api-key-stdin
    rules:
    - if: $CI_COMMIT_REF_PROTECTED == "true"

    The last line of the script: matters. Writing deploy --api-key=$PROD_API_KEY looks equivalent, but it is not: GitLab masking only filters the logs. A process's command line stays readable by the other users of the machine, with ps or in /proc/<pid>/cmdline, so by a neighbouring job on a shared runner. Pass the value through stdin (the --api-key-stdin option is fictional, modelled on docker login --password-stdin) or through an environment variable the tool reads itself: a process's environment is readable only by its owner and by root.

  2. Dedicated runners per environment

    deploy_prod:
    tags:
    - production
    - secure
    environment:
    name: production
  3. Isolated review apps

    review:
    environment:
    name: review/$CI_COMMIT_REF_SLUG
    auto_stop_in: 1 week
  4. Protected branches and merge rules

    • Require 2 approvals for main
    • Successful pipeline required
    • No direct push
  5. Secrets through OIDC and Vault (recommended)

    Use OIDC ID tokens for authentication without static secrets:

    deploy_prod:
    id_tokens:
    VAULT_ID_TOKEN:
    aud: https://vault.example.com
    secrets:
    DATABASE_PASSWORD:
    vault:
    engine:
    name: kv-v2
    path: production
    path: db
    field: password
    token: $VAULT_ID_TOKEN
    file: false # an environment variable, not the path of a file
    script:
    # The tool reads DATABASE_PASSWORD from its environment:
    # no --db-password=..., which would show in `ps`
    - deploy

    The job receives an OIDC token that Vault checks before issuing the secret. By default, GitLab drops that secret into a file and the variable only holds its path: file: false makes it an ordinary variable, which the tool reads from its environment. The secrets: keyword with Vault requires the Premium or Ultimate tier of GitLab.

  6. Job audit with needs

    needs declares the jobs this one depends on: a security scan that fails therefore stops the deployment from going out.

    deploy:
    needs:
    - test
    - security_scan
    when: on_success # Only if the previous jobs succeed

Target architecture aligned with SLSA

Once the seven pillars are in place, the next question is that of proof: how to show a third party that the published artifact really comes from this build. That is the domain of the SLSA framework, and it is where hardening stops being internal hygiene and becomes a verifiable commitment. The section sets the target, then maps each pillar to the SLSA level it helps reach.

Overview

This architecture is an SLSA level 3-inspired target, not automatic compliance. SLSA requirements are precise and depend on implementation details.

Target architecture of a hardened build: Git source with signed commits, a builder on an ephemeral runner with a hermetic build and allow-listed egress, artifacts with an SBOM and a signed provenance, verification before deployment.Source: Git, signed commitsBuilder: ephemeral runner, hermetic build, allow-listed egressArtifacts: image, SBOM, signed provenanceVerification before deployment
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %

SLSA mapping to the hardening pillars

This table is a simplified operational reading linking build hardening to SLSA progression; it does not replace reading the official SLSA requirements.

SLSA levelRequirementsPillars covered
Level 1Basic provenanceEphemerality (partial), Immutability
Level 2Signed provenance, build serviceEphemerality, Isolation, Verification, Immutability
Level 3Full isolation, unforgeable provenanceEvery pillar

Monitoring and detection

Hardening reduces the attack surface, it does not guarantee that no attack will succeed. A compromised pipeline shows up through measurable behaviour deviations: abnormal duration, new network destinations, changes outside the review circuit. You still need to collect these signals and know which ones deserve an alert, which the two tables below detail.

Warning signs to watch

These five signals can be observed without specific tooling, from the data the forge already produces. The first one, an abnormal job duration, is often the earliest: encrypting, mining or exfiltrating costs CPU time, and it shows against the job's historical average.

SignalWhat it indicatesAction
Unusually long jobExfiltration, crypto miningAlert and investigate
Unexpected network connectionsCommand and control, exfiltrationBlock and alert
Workflow change without a PRCompromiseBlock and revoke
Repeated signature failuresBypass attemptAlert
New maintainer on an action in useSupply chain riskReview the action

Monitoring tools

None of these tools covers the whole spectrum: they split by layer, the runner's network, the dependencies, the actions on the repository, the container runtime. The GitHub Audit Log needs no installation and answers "who changed a security setting, and when" (access, secrets, runners); for "who modified this workflow file", the Git history is the authority.

ToolFunction
Harden-RunnerLogs network connections from runners
Dependency ReviewAlerts on new vulnerable dependencies
GitHub Audit LogAdministration and access events at organisation level
FalcoRuntime security for Kubernetes runners
Datadog CI VisibilityPipeline metrics and traces

What this guide does not cover

Build hardening is an essential piece, but not enough on its own. The table says where each neighbouring topic is handled, so that this lesson does not have to cover the whole supply chain:

TopicWhere to handle it
Source code securityCode review, SAST, contribution policies
Dependency securitySBOM, SCA, CVE watch, lockfiles
Artifact signing and provenanceSigstore, SLSA
Cluster-side admission policyKyverno, OPA Gatekeeper, provenance verification
Third-party maintainer managementDue diligence, audit of the actions and packages used

Realistic prioritisation

If you start from scratch, here is the recommended order. Each step builds on the previous one, and the first three bring the biggest gain for the smallest effort:

  1. Minimal permissions: immediate impact, easy to implement

  2. Pinning actions and images: protects against silent changes

  3. OIDC for cloud deployments: removes static secrets

  4. Ephemeral runners: removes persistence

  5. Egress audit (observation mode): understand the network traffic

  6. Egress blocking: after validating the legitimate destinations

  7. Fully hermetic architecture: long-term goal

Cost, security and operability trade-offs

Hardening has a cost. Own these trade-offs rather than suffering them: each measure in the table brings a security benefit and imposes some friction that the team has to accept knowingly.

MeasureSecurity benefitCost or friction
Ephemeral VM runnersStrong isolationMore expensive, slower than containers
Strict egressBlocks exfiltrationRequires maintaining the allow-list
OIDCNo more static secretsInitial IAM setup
Mandatory workflow reviewBlocks malicious changesSlightly slows development
Pinning by SHAPrevents stealthy changesMaintaining updates

Key points

The 7 essential points of this guide:

  • The CI/CD pipeline is a critical target: it has privileged access to sensitive resources
  • 7 defence pillars: ephemerality, isolation, least privilege, egress control, short secrets (OIDC), input verification, input immutability
  • Ephemeral runners remove persistence, but a container is not automatically as isolated as a VM
  • OIDC replaces static secrets, but the security level depends on the trust configured on the cloud side; whatever the secret, never pass it as a command argument, the command line can be read with ps
  • Hardening is a practical prerequisite for progressing towards SLSA, not an automatic guarantee of compliance
  • Prioritise: permissions, pinning and OIDC first; strict egress and hermetic architecture next
  • Evidence expected by SOCLE-ORC-EPH-1 (in French): a runner that runs a single job and is then destroyed. The ARC scale set configuration, or the equivalent ephemeral runner, provides it.

Knowledge check

Check that the essentials of this lesson are in place. The questions only cover what has just been explained here.

Knowledge check

Check what you have learned with this interactive quiz

8 questions
8 min
70% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer