Prerequisites
- Target system, dependencies and environment configured.
Usage
Purpose
The CI/CD pipeline has write access to production and runs whatever the latest commit tells it to — which makes it one of the most powerful and most attacked parts of the software supply chain. A compromised pipeline can inject malicious code into every build, steal secrets, and deploy to production. This skill covers hardening the pipeline itself so it doesn't become the attack path — securing the thing that secures everything else it touches.
When to use it
Hardening any CI/CD setup, especially given how often pipelines are the target of supply-chain attacks. It's foundational: a pipeline that scans code but is itself compromised provides false assurance. Securing the pipeline is as important as what the pipeline does.
Procedure
- Least-privilege the pipeline's access. Pipelines often run with broad permissions (deploy to prod, read all secrets, write to any repo). Scope each pipeline/job to the minimum it needs — a build job doesn't need deploy credentials; a test job doesn't need production access. Over-privileged pipelines turn one compromised workflow into total compromise.
- Pin third-party actions/dependencies — a key supply-chain control. Pipelines pull in reusable actions/steps (GitHub Actions, GitLab includes), and referencing them by mutable tag (
@v3) means a compromised or repointed action runs in your pipeline. Pin third-party actions by commit SHA, not tag, so you run exactly the reviewed code. A tag can be moved to malicious code; a SHA can't.
Apply the same review to service images used by integration tests. A mutable image tag can disappear or point to different contents. Check the publisher and registry, choose a published version, and record what the test actually exercises. For stronger repeatability, pin the reviewed image digest as well.
- Protect the branches and the pipeline config. Require reviews on the branches that trigger deployment, and protect the pipeline configuration itself (the workflow files) — if an attacker can edit the pipeline config in a PR, they can make it do anything. Require review for changes to pipeline definitions specifically.
- Secure secret handling. Pipeline secrets (deploy keys, cloud credentials, signing keys) are high-value; scope them to the jobs that need them, don't expose them to PR builds from forks (a common exfiltration path — a malicious PR reads the secrets), and prefer short-lived/OIDC-based credentials over long-lived static secrets.
- Guard against poisoned pipeline execution. An attacker who can influence what the pipeline runs (via a PR that modifies build scripts, or injects into a build step) can execute code in your trusted CI environment. Don't run untrusted PR code with access to secrets/production; separate untrusted-PR builds from privileged pipelines.
- Isolate and clean runners (the secure-runners skill) — especially self-hosted runners, which persist state between jobs and can be a foothold.
- Log and monitor pipeline activity. Treat the pipeline as the high-value target it is — log configuration changes, secret access, and deployments, and alert on anomalies (a workflow suddenly accessing secrets it never did).
Check a test service image / Vérifier une image de test
When a test fails before its assertions because the runner cannot pull an image, isolate the registry error before changing application code. In the MinIO test image case, minio/minio:latest returned 404 in CI. The replacement was reviewed as an S3-compatible test double and the integration test was changed to assert the bucket created after publication. That proves the tested S3 path, not full MinIO compatibility.
Quand un test échoue avant ses assertions parce que le runner ne peut pas télécharger une image, identifier d'abord la réponse du registre. Dans le cas de minio/minio:latest, la CI recevait une erreur 404. Le substitut S3 choisi a été vérifié à la source, puis le test d'intégration a contrôlé la création du bucket après publication. Cela valide ce trajet S3 précis, pas toute la compatibilité MinIO.
# Use the exact image reference from the failing test or CI log.
docker manifest inspect adobe/s3mock:5.2.3 >/dev/null
docker pull adobe/s3mock:5.2.3
docker image inspect adobe/s3mock:5.2.3 --format '{{json .RepoDigests}}'
Confirm the repository and tag on the publisher's own page, then review the digest returned by the registry. Run the affected integration test and check a behavior assertion against the service; a successful pull alone does not prove compatibility. Treat 401 (authorization), 404 (reference unavailable), and network timeouts as different causes. Do not print registry credentials into CI logs.
Confirmer le dépôt et la version sur la page de l'éditeur, puis relever le digest fourni par le registre. Exécuter le test d'intégration concerné et vérifier une assertion métier contre le service : un téléchargement réussi ne prouve pas la compatibilité. Distinguer 401 (autorisation), 404 (référence indisponible) et délai réseau. Ne jamais afficher les identifiants du registre dans les logs CI.
Cheatsheet
the pipeline has WRITE access to prod + runs whatever the latest commit says
-> most powerful + most attacked part of the supply chain. secure the securer.
harden
LEAST PRIVILEGE per job (build != deploy creds ; test != prod access)
over-privileged pipeline = one workflow compromise -> total compromise
PIN third-party actions by COMMIT SHA not tag (@v3 mutable -> repointed to malicious)
PROTECT branches + the PIPELINE CONFIG itself (edit config in a PR = do anything)
-> require review for workflow-definition changes
SECRETS: scope to jobs, NOT exposed to fork-PR builds (malicious PR reads them),
prefer short-lived / OIDC over static
POISONED PIPELINE EXECUTION: don't run untrusted PR code WITH secrets/prod access
-> separate untrusted-PR builds from privileged pipelines
ISOLATE + clean runners (esp. self-hosted — persist state) [secure-runners]
LOG + monitor (config changes, secret access, deploys) — it's a high-value target
Reading the pipeline
- Over-privileged pipeline jobs (build jobs with deploy credentials, broad secret access) = one compromised workflow becomes total compromise; least-privilege per job is the core hardening. A common, high-impact finding.
- Third-party actions referenced by mutable tag (
@v3) = a compromised or repointed action runs in your trusted pipeline — a real supply-chain vector. Pin by commit SHA.
- Pipeline config editable via PR without review = an attacker's PR can make the pipeline do anything (exfil secrets, inject code, deploy). Protect workflow definitions specifically.
- Secrets exposed to fork-PR builds = a malicious PR from a fork can read and exfiltrate your pipeline secrets; a classic attack. Don't expose secrets to untrusted PR builds.
- Untrusted PR code running with secret/prod access = poisoned pipeline execution; the attacker executes code in your trusted CI. Separate untrusted builds from privileged ones.
- A hardened pipeline (least privilege, SHA-pinned actions, protected config, scoped secrets, isolated runners, monitored) = the securer is itself secure; it can't be turned into the attack path.
The fix / best practice
- Least-privilege every job to the minimum access it needs; separate build, test, and deploy privileges.
- Pin third-party actions by commit SHA, not tag, and review them before adopting.
- Protect branches and pipeline configuration with required review, especially the workflow files themselves.
- Scope secrets to jobs, keep them away from fork-PR builds, and prefer short-lived/OIDC credentials over static secrets.
- Separate untrusted-PR execution from privileged pipelines to prevent poisoned pipeline execution.
- Isolate and clean runners, and log/monitor the pipeline as the high-value target it is.
Pitfalls
- Over-privileged pipelines. Broad access turns one compromised workflow into total compromise; scope every job to least privilege. The most common and impactful pipeline weakness.
- Mutable action references.
@v3 and tags can be repointed to malicious code; pin third-party actions by commit SHA.
- Unprotected pipeline config. If an attacker's PR can edit the workflow, they control the pipeline. Require review for pipeline-definition changes.
- Secrets in fork-PR builds. A malicious external PR reads and exfiltrates them; never expose secrets to untrusted PR builds.
- Running untrusted code with privileges. Poisoned pipeline execution lets an attacker run code in trusted CI; separate untrusted builds from privileged pipelines.
- Trusting the pipeline blindly. A pipeline that scans code but is itself compromised gives false assurance; harden and monitor the pipeline itself.
References
- OWASP CI/CD Security Top 10 and SLSA framework
- GitHub Actions / GitLab CI security hardening documentation
- The secure-runners, artifact-integrity, and build-provenance-slsa skills
- The software-supply-chain-security domain
- Adobe S3Mock and its published Docker tags
Inputs
- Relevant source code, logs, network traces, or system specifications.
Outputs
- Analysis findings, security audit report, or generated code artifacts.
1---2format: "v2"3name: "pipeline-hardening"4title: "Pipeline Hardening"5title_fr: "Durcissement du pipeline"6description: "Use when securing the CI/CD pipeline itself — least-privilege runners, pinned actions, protected branches, and the controls that stop the pipeline from becoming an attack path to production."7description_fr: "À utiliser pour sécuriser le pipeline CI/CD lui-même — runners à privilèges minimaux, actions épinglées, branches protégées et les contrôles qui empêchent le pipeline de devenir une voie d'attaque vers la production."8domain: "08-devsecops-and-cicd-security"9tags: [cybersecurity, engineering, best-practices]10maturity: "stable"11audience: ["backend-engineer", "security-engineer", "coding-agent"]12requires: ["bash", "git"]13updated: "2026-10-14"14metadata:15 source: https://skillmd.com/skills/jihedbfr-art/pipeline-hardening16---17181920## Prerequisites21- Target system, dependencies and environment configured.2223## Usage24### Purpose2526The CI/CD pipeline has write access to production and runs whatever the latest commit tells it to — which makes it one of the most powerful and most attacked parts of the software supply chain. A compromised pipeline can inject malicious code into every build, steal secrets, and deploy to production. This skill covers hardening the pipeline itself so it doesn't become the attack path — securing the thing that secures everything else it touches.2728### When to use it2930Hardening any CI/CD setup, especially given how often pipelines are the target of supply-chain attacks. It's foundational: a pipeline that scans code but is itself compromised provides false assurance. Securing the pipeline is as important as what the pipeline does.3132### Procedure33341. **Least-privilege the pipeline's access.** Pipelines often run with broad permissions (deploy to prod, read all secrets, write to any repo). Scope each pipeline/job to the minimum it needs — a build job doesn't need deploy credentials; a test job doesn't need production access. Over-privileged pipelines turn one compromised workflow into total compromise.352. **Pin third-party actions/dependencies — a key supply-chain control.** Pipelines pull in reusable actions/steps (GitHub Actions, GitLab includes), and referencing them by mutable tag (`@v3`) means a compromised or repointed action runs in your pipeline. Pin third-party actions by **commit SHA**, not tag, so you run exactly the reviewed code. A tag can be moved to malicious code; a SHA can't.36 Apply the same review to service images used by integration tests. A mutable image tag can disappear or point to different contents. Check the publisher and registry, choose a published version, and record what the test actually exercises. For stronger repeatability, pin the reviewed image digest as well.373. **Protect the branches and the pipeline config.** Require reviews on the branches that trigger deployment, and protect the pipeline configuration itself (the workflow files) — if an attacker can edit the pipeline config in a PR, they can make it do anything. Require review for changes to pipeline definitions specifically.384. **Secure secret handling.** Pipeline secrets (deploy keys, cloud credentials, signing keys) are high-value; scope them to the jobs that need them, don't expose them to PR builds from forks (a common exfiltration path — a malicious PR reads the secrets), and prefer short-lived/OIDC-based credentials over long-lived static secrets.395. **Guard against poisoned pipeline execution.** An attacker who can influence what the pipeline runs (via a PR that modifies build scripts, or injects into a build step) can execute code in your trusted CI environment. Don't run untrusted PR code with access to secrets/production; separate untrusted-PR builds from privileged pipelines.406. **Isolate and clean runners** (the secure-runners skill) — especially self-hosted runners, which persist state between jobs and can be a foothold.417. **Log and monitor pipeline activity.** Treat the pipeline as the high-value target it is — log configuration changes, secret access, and deployments, and alert on anomalies (a workflow suddenly accessing secrets it never did).4243### Check a test service image / Vérifier une image de test4445When a test fails before its assertions because the runner cannot pull an image, isolate the registry error before changing application code. In the MinIO test image case, `minio/minio:latest` returned 404 in CI. The replacement was reviewed as an S3-compatible test double and the integration test was changed to assert the bucket created after publication. That proves the tested S3 path, not full MinIO compatibility.4647Quand un test échoue avant ses assertions parce que le runner ne peut pas télécharger une image, identifier d'abord la réponse du registre. Dans le cas de `minio/minio:latest`, la CI recevait une erreur 404. Le substitut S3 choisi a été vérifié à la source, puis le test d'intégration a contrôlé la création du bucket après publication. Cela valide ce trajet S3 précis, pas toute la compatibilité MinIO.4849```bash50# Use the exact image reference from the failing test or CI log.51docker manifest inspect adobe/s3mock:5.2.3 >/dev/null52docker pull adobe/s3mock:5.2.353docker image inspect adobe/s3mock:5.2.3 --format '{{json .RepoDigests}}'54```5556Confirm the repository and tag on the publisher's own page, then review the digest returned by the registry. Run the affected integration test and check a behavior assertion against the service; a successful pull alone does not prove compatibility. Treat 401 (authorization), 404 (reference unavailable), and network timeouts as different causes. Do not print registry credentials into CI logs.5758Confirmer le dépôt et la version sur la page de l'éditeur, puis relever le digest fourni par le registre. Exécuter le test d'intégration concerné et vérifier une assertion métier contre le service : un téléchargement réussi ne prouve pas la compatibilité. Distinguer 401 (autorisation), 404 (référence indisponible) et délai réseau. Ne jamais afficher les identifiants du registre dans les logs CI.5960### Cheatsheet6162```63the pipeline has WRITE access to prod + runs whatever the latest commit says64 -> most powerful + most attacked part of the supply chain. secure the securer.6566harden67 LEAST PRIVILEGE per job (build != deploy creds ; test != prod access)68 over-privileged pipeline = one workflow compromise -> total compromise69 PIN third-party actions by COMMIT SHA not tag (@v3 mutable -> repointed to malicious)70 PROTECT branches + the PIPELINE CONFIG itself (edit config in a PR = do anything)71 -> require review for workflow-definition changes72 SECRETS: scope to jobs, NOT exposed to fork-PR builds (malicious PR reads them),73 prefer short-lived / OIDC over static74 POISONED PIPELINE EXECUTION: don't run untrusted PR code WITH secrets/prod access75 -> separate untrusted-PR builds from privileged pipelines76 ISOLATE + clean runners (esp. self-hosted — persist state) [secure-runners]77 LOG + monitor (config changes, secret access, deploys) — it's a high-value target78```7980### Reading the pipeline8182- **Over-privileged pipeline jobs** (build jobs with deploy credentials, broad secret access) = one compromised workflow becomes total compromise; least-privilege per job is the core hardening. A common, high-impact finding.83- **Third-party actions referenced by mutable tag** (`@v3`) = a compromised or repointed action runs in your trusted pipeline — a real supply-chain vector. Pin by commit SHA.84- **Pipeline config editable via PR without review** = an attacker's PR can make the pipeline do anything (exfil secrets, inject code, deploy). Protect workflow definitions specifically.85- **Secrets exposed to fork-PR builds** = a malicious PR from a fork can read and exfiltrate your pipeline secrets; a classic attack. Don't expose secrets to untrusted PR builds.86- **Untrusted PR code running with secret/prod access** = poisoned pipeline execution; the attacker executes code in your trusted CI. Separate untrusted builds from privileged ones.87- **A hardened pipeline** (least privilege, SHA-pinned actions, protected config, scoped secrets, isolated runners, monitored) = the securer is itself secure; it can't be turned into the attack path.8889### The fix / best practice9091- **Least-privilege every job** to the minimum access it needs; separate build, test, and deploy privileges.92- **Pin third-party actions by commit SHA**, not tag, and review them before adopting.93- **Protect branches and pipeline configuration** with required review, especially the workflow files themselves.94- **Scope secrets to jobs**, keep them away from fork-PR builds, and prefer short-lived/OIDC credentials over static secrets.95- **Separate untrusted-PR execution** from privileged pipelines to prevent poisoned pipeline execution.96- **Isolate and clean runners**, and **log/monitor** the pipeline as the high-value target it is.9798### Pitfalls99100- **Over-privileged pipelines.** Broad access turns one compromised workflow into total compromise; scope every job to least privilege. The most common and impactful pipeline weakness.101- **Mutable action references.** `@v3` and tags can be repointed to malicious code; pin third-party actions by commit SHA.102- **Unprotected pipeline config.** If an attacker's PR can edit the workflow, they control the pipeline. Require review for pipeline-definition changes.103- **Secrets in fork-PR builds.** A malicious external PR reads and exfiltrates them; never expose secrets to untrusted PR builds.104- **Running untrusted code with privileges.** Poisoned pipeline execution lets an attacker run code in trusted CI; separate untrusted builds from privileged pipelines.105- **Trusting the pipeline blindly.** A pipeline that scans code but is itself compromised gives false assurance; harden and monitor the pipeline itself.106107### References108109- OWASP CI/CD Security Top 10 and SLSA framework110- GitHub Actions / GitLab CI security hardening documentation111- The secure-runners, artifact-integrity, and build-provenance-slsa skills112- The software-supply-chain-security domain113- [Adobe S3Mock](https://github.com/adobe/S3Mock) and its [published Docker tags](https://hub.docker.com/r/adobe/s3mock/tags)114115## Inputs116- Relevant source code, logs, network traces, or system specifications.117118## Outputs119- Analysis findings, security audit report, or generated code artifacts.