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
- Basic knowledge of CI/CD pipelines (GitHub Actions or GitLab CI)
- Recommended reading: Living Off The Pipeline
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:
| Feature | Associated risk |
|---|---|
| Has access to production secrets | Credential exfiltration |
| Can modify the code (merge, tag) | Backdoor injection |
| Signs artifacts | Signing compromised artifacts |
| Publishes to registries | Malware 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.
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.
| Attack | Vector | Impact |
|---|---|---|
| Codecov (2021) | Bash Uploader script tampered with at the source, then run in customers' CI | Exfiltration of CI secrets to the attacker |
| Event-stream (2018) | Compromised maintainer, malicious code | Bitcoin theft through an npm dependency |
| SolarWinds (2020) | Compromise of the build system | Backdoor installed by nearly 18,000 customers |
| tj-actions (2025) | Compromised GitHub action | Exfiltration of secrets |
| xz-utils (2024) | Modified build scripts | SSH 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.
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.
| Mode | Security | Performance | Cost |
|---|---|---|---|
| Persistent runner | Low | Fast | Low |
| Ephemeral VM runner | Very good baseline isolation | Medium | Medium |
| Ephemeral container runner | Good level possible, depending on configuration | Fast | Low |
| GitHub-hosted | High | Medium | High |
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:
# ARC controllerhelm 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-sethelm 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-setarc-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.
Configure Docker runners with reinforced hygiene (less cache and persistence, without being truly ephemeral runners in the infrastructure sense). The three useful options go in the [runners.docker] section of config.toml:
# config.toml - Low-persistence Docker runner[[runners]] name = "docker-reinforced-hygiene" executor = "docker"
[runners.docker] image = "debian:trixie-slim@sha256:a99cfc517144bc59b1978475ec53b46ecabec7e43635402ee5b77cc54cd1b20a" privileged = false disable_cache = true # no automatically created cache volumes pull_policy = "always"disable_cache only switches off the local cache based on Docker volumes, not the distributed cache you might configure elsewhere, and pull_policy = "always" pulls the image again for every job instead of reusing a local copy.
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:
| Kind | Description | Mechanisms |
|---|---|---|
| Execution isolation | Technical separation (processes, network, filesystem) | Ephemeral runners, network policies, dedicated containers or VMs |
| Logical separation | Access control to resources (secrets, deployments) | Environments, permissions, approvals |
# No permission by default, each job reopens only what it needspermissions: {}
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 buildbuild: stage: build # Logical separation through an environment (scoped variables, approvals) environment: name: production
# PROD_API_KEY is restricted to this environment in Settings > CI/CD > Variables (Environment scope field) variables: API_KEY: $PROD_API_KEY
# Dedicated runner through tags tags: - production - isolated
script: - make buildPillar 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 permissionspermissions: {}
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 deployGitHub 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).
| Permission | When to use it | Risk if too broad |
|---|---|---|
contents: read | Code checkout | Lets the job read the code (a risk if given to untrusted code) |
contents: write | Push, merge, tags | Modifying the repository, tags, releases, code injection |
packages: write | Publishing images or packages | Malware distribution through the registry |
id-token: write | OIDC to cloud providers | Cloud access if the provider-side trust is misconfigured |
actions: write | Workflow management | Modifying or cancelling sensitive workflows |
security-events: write | Uploading scan results | Potential 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 buildAfter 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:443Kubernetes network policies (self-hosted)
This example shows a port restriction (443 only), not a true allow-list of destinations:
apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata: name: runner-egress-port-restrictionspec: 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-listPillar 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 secret | Risk |
|---|---|
| AWS access key | Valid indefinitely, exfiltrable |
| Docker Hub token | Lets you publish images |
| npm token | Lets you publish packages |
| Kubeconfig | Full 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.
- GitHub generates an OIDC token (JWT) carrying the workflow's identity.
- The cloud provider checks the token and issues temporary credentials.
- 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-bucketjobs: 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: Authenticate to Google Cloud (OIDC) uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0 with: workload_identity_provider: projects/123/locations/global/workloadIdentityPools/my-pool/providers/github service_account: deploy@my-project.iam.gserviceaccount.com
- name: Deploy run: gcloud run deploy my-service --image=...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: Azure Login (OIDC) uses: azure/login@532459ea530d8321f2fb9bb10d1e0bcf23869a43 # v3.0.0 with: client-id: ${{ secrets.AZURE_CLIENT_ID }} tenant-id: ${{ secrets.AZURE_TENANT_ID }} subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} # No client secret, OIDC is used
- name: Deploy run: az webapp deploy ...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.
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.
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 donePillar 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.
| Input | Risk if not frozen | Good practice |
|---|---|---|
| GitHub actions | A mutable tag can be changed | Pin by SHA |
| Docker images | latest or version tag can change | Pin by digest |
| Dependencies | Dynamic resolution can change | Mandatory lockfiles |
| Downloaded scripts | Content can be changed at the source, as with Codecov | Forbid 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 digestFROM python:3.12-slim@sha256:dddfd7e07f9d15aeeca61529320492139d21cac7f0070c00609243e51e4e0016The 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:
curl -fsSLO https://example-vendor.tld/tool-1.2.3-linux-amd64.tar.gzcurl -fsSLO https://example-vendor.tld/tool-1.2.3-checksums.txtsha256sum --check --ignore-missing tool-1.2.3-checksums.txttar -xzf tool-1.2.3-linux-amd64.tar.gzThe 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).
-
Minimal permissions globally
Switch everything off at workflow level with
permissions: {}, then reopen job by job. A globalcontents: readlooks harmless, but it gives access to the code to every job, including those running third-party dependencies.# At workflow level: no permission by defaultpermissions: {}jobs:lint:permissions:contents: read -
Pin actions by SHA
# ❌ Bad- uses: actions/checkout@v4# Good: commit SHA, version as a comment- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1Automate 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.
-
OIDC for every cloud deployment
Replace static AWS, GCP or Azure secrets with OIDC.
-
Harden-Runner for egress control
- uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0with:egress-policy: audit # then block -
Environments for sensitive secrets
Configure environments with approval for production.
-
Mandatory code review for workflows
Add the
.github/workflows/**files to CODEOWNERS. -
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.
-
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-stdinrules:- if: $CI_COMMIT_REF_PROTECTED == "true"The last line of the
script:matters. Writingdeploy --api-key=$PROD_API_KEYlooks 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, withpsor in/proc/<pid>/cmdline, so by a neighbouring job on a shared runner. Pass the value through stdin (the--api-key-stdinoption is fictional, modelled ondocker 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. -
Dedicated runners per environment
deploy_prod:tags:- production- secureenvironment:name: production -
Isolated review apps
review:environment:name: review/$CI_COMMIT_REF_SLUGauto_stop_in: 1 week -
Protected branches and merge rules
- Require 2 approvals for
main - Successful pipeline required
- No direct push
- Require 2 approvals for
-
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.comsecrets:DATABASE_PASSWORD:vault:engine:name: kv-v2path: productionpath: dbfield: passwordtoken: $VAULT_ID_TOKENfile: false # an environment variable, not the path of a filescript:# The tool reads DATABASE_PASSWORD from its environment:# no --db-password=..., which would show in `ps`- deployThe 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: falsemakes it an ordinary variable, which the tool reads from its environment. Thesecrets:keyword with Vault requires the Premium or Ultimate tier of GitLab. -
Job audit with
needsneedsdeclares the jobs this one depends on: a security scan that fails therefore stops the deployment from going out.deploy:needs:- test- security_scanwhen: 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.
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 level | Requirements | Pillars covered |
|---|---|---|
| Level 1 | Basic provenance | Ephemerality (partial), Immutability |
| Level 2 | Signed provenance, build service | Ephemerality, Isolation, Verification, Immutability |
| Level 3 | Full isolation, unforgeable provenance | Every 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.
| Signal | What it indicates | Action |
|---|---|---|
| Unusually long job | Exfiltration, crypto mining | Alert and investigate |
| Unexpected network connections | Command and control, exfiltration | Block and alert |
| Workflow change without a PR | Compromise | Block and revoke |
| Repeated signature failures | Bypass attempt | Alert |
| New maintainer on an action in use | Supply chain risk | Review 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.
| Tool | Function |
|---|---|
| Harden-Runner | Logs network connections from runners |
| Dependency Review | Alerts on new vulnerable dependencies |
| GitHub Audit Log | Administration and access events at organisation level |
| Falco | Runtime security for Kubernetes runners |
| Datadog CI Visibility | Pipeline 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:
| Topic | Where to handle it |
|---|---|
| Source code security | Code review, SAST, contribution policies |
| Dependency security | SBOM, SCA, CVE watch, lockfiles |
| Artifact signing and provenance | Sigstore, SLSA |
| Cluster-side admission policy | Kyverno, OPA Gatekeeper, provenance verification |
| Third-party maintainer management | Due 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:
-
Minimal permissions: immediate impact, easy to implement
-
Pinning actions and images: protects against silent changes
-
OIDC for cloud deployments: removes static secrets
-
Ephemeral runners: removes persistence
-
Egress audit (observation mode): understand the network traffic
-
Egress blocking: after validating the legitimate destinations
-
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.
| Measure | Security benefit | Cost or friction |
|---|---|---|
| Ephemeral VM runners | Strong isolation | More expensive, slower than containers |
| Strict egress | Blocks exfiltration | Requires maintaining the allow-list |
| OIDC | No more static secrets | Initial IAM setup |
| Mandatory workflow review | Blocks malicious changes | Slightly slows development |
| Pinning by SHA | Prevents stealthy changes | Maintaining 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
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
Review
(0/0)Result saved on this device. It will be sent to your account at the next sync. Sync now
Score by domain
A domain groups several guides and gets several questions, so its score is more reliable than a per-topic score, which often rests on a single question.
Summary
Strengths
No topic passed at 80% on at least two questions yet.
Weak areas
No topic below the pass mark.
Recommended next
Hints before you try again?
Continue the course: Blocking a pipeline does not improve security: gates and guardrails
A new full quiz with random questions
Work again only on the questions you missed