Skip to main content

CI/CD pipeline security: SaaS deployment hardening checklist

Harden SaaS CI/CD workflows with least-privilege tokens, trusted actions, isolated runners, protected releases, short-lived deployment identity and build evidence.

In this guide

Why does CI/CD pipeline security matter?

A CI/CD pipeline turns code into tested artifacts and may publish or deploy them. Because pipelines can access source, signing keys, cloud accounts and production, a compromised workflow can affect more than one application server. Treat the build and deployment system as production infrastructure: map its identities and trust boundaries, reduce the authority of each job and make the release path verifiable.

Map workflow triggers, identities and release boundaries

List repositories, workflow events, third-party actions, runners, artifact registries, environments and cloud roles. Mark which triggers can run code from a fork or untrusted contributor and which jobs can access production credentials or write to a release. Give every deployment workflow an owner and remove unused triggers and permissions.

Set minimum token permissions for each workflow

Declare only the repository permissions a job needs and keep the default token read-only where possible. Split build, test, publish and deploy jobs so a pull-request test cannot inherit production write access. Protect environment secrets with reviewer approval and branch or tag restrictions where the platform supports them.

Pin and review third-party build components

Review the source and permissions of each action or plugin. For GitHub Actions, pin third-party actions to a verified full commit SHA when practical, keep a controlled update process and restrict which actions may run. A version tag is easier to update but may move to different code, so it is a mutable trust decision.

CI/CD trust-boundary review
Workflow / triggerCode trust levelToken permissionsSecrets / environmentReviewer and release evidence
Pull request checks
Release build
Production deploy

How should a SaaS team isolate builds and deployment credentials?

Keep untrusted contribution workflows away from privileged secrets

Do not run fork-controlled code in a privileged event context that can access repository secrets or write tokens. In particular, avoid using `pull_request_target` to check out and execute an untrusted pull request. Separate review and test jobs from protected deployment jobs, and pass only reviewed artifacts across the boundary.

Use disposable runners for sensitive builds

Prefer clean, short-lived runners for jobs that handle production credentials or signed artifacts. Self-hosted runners need isolation between jobs, restricted network access, patching and a cleanup plan; a persistent worker can carry attacker-controlled files or processes into a later build. Do not expose the container engine socket or broad host credentials to ordinary build steps.

Use workload identity instead of long-lived cloud keys where supported

A deployment can exchange a trusted workflow identity for a short-lived cloud credential through an OIDC trust relationship. Restrict that trust by repository, branch or protected environment claims, and grant only the target deployment role. Validate the provider’s exact claim mapping; a broad trust rule can let another workflow assume the role.

How do you make a release traceable and recoverable?

Build once and promote the same artifact

Create a versioned artifact from a reviewed commit, record its digest and promote that artifact through test and production. Rebuilding independently for each environment makes it harder to prove that the tested object is the one deployed. Keep source commit, dependency inventory, build identity and release approval connected.

Add provenance and artifact integrity checks

Where supported, generate build provenance or an attestation that identifies the source and build process, then verify it before release. Restrict who can publish or replace production artifacts and alert on unexpected releases. Provenance can improve traceability, but it does not prove source code is benign or that the build system itself is uncompromised.

Monitor workflow changes and rehearse credential containment

Record changes to workflow files, runner settings, environment protections, token permissions and release policies. Alert on unusual secret access, unexpected deployment identity use and artifact replacement. Practice disabling a workflow, revoking a cloud identity and rebuilding a release after a runner or action is suspected compromised.

CI/CD pipeline security questions

Can a pull-request workflow access deployment secrets?

It should not need them. Run untrusted code with minimal read-only permissions and without production secrets. Put deployment in a separate protected workflow or environment that accepts only reviewed code and trusted artifacts.

Is a pinned action automatically safe?

No. Pinning a full commit SHA makes the referenced code immutable, but reviewers still need to assess the action’s source, permissions, maintenance and behavior. Update pins through a reviewed process so security fixes are not missed.

Does OIDC eliminate deployment risk?

No. OIDC can replace a long-lived cloud key with short-lived credentials, but the trust policy and role still need tight scope. A compromised trusted workflow may still obtain whatever authority the role grants.

Does a green CI pipeline prove the release is secure?

No. Automated checks cover selected conditions and can miss design flaws, compromised dependencies or build-system compromise. Use threat modeling, code review, dependency controls, artifact verification, production monitoring and incident response alongside CI checks.