Nexus Void AI Research

CI/CD Security, GitHub Actions, Pipeline Security, Supply Chain, Merge Gate, ARGUS

How to Secure a CI/CD Pipeline in GitHub Actions

How to secure a CI/CD pipeline in GitHub Actions: least-privilege tokens, SHA-pinned actions, scoped secrets, and a required security check before merge.

To secure a CI/CD pipeline in GitHub Actions, lock down four things: the permissions your workflows run with, the third-party actions you depend on, the secrets the pipeline can read, and the gate that decides what's allowed to merge. Set least-privilege permissions, pin every action to a full commit SHA, scope secrets, avoid running untrusted code with pull_request_target, and make a security check required before merge.

Last updated 31 October 2026.

A CI/CD pipeline is high-value because it holds credentials and can push to production, so a poisoned workflow or a compromised action can turn one pull request into a full supply-chain compromise. Attackers target pipelines directly, through malicious dependencies pulled during a build, tampered third-party actions or over-privileged tokens, because owning the pipeline means owning everything it ships. This guide sits in our software supply chain security cluster.

What are the biggest CI/CD security risks?

The OWASP Top 10 CI/CD Security Risks captures the pattern. For GitHub Actions users, a few dominate:

Risk

What goes wrong

Mitigation

Over-privileged GITHUB_TOKEN

A compromised step can push code or change settings

Set least-privilege permissions per workflow and job

Unpinned third-party actions

A tag is moved to malicious code and your pipeline runs it

Pin actions to a full commit SHA

Exposed secrets

Secrets echoed to logs or readable by every job

Scope secrets to environments; never print them

Untrusted pull_request_target

A fork's code runs with your repository's secrets

Don't check out and run untrusted code in that context

Poisoned dependencies at build

A malicious package runs install scripts in CI

Scan and verify what the build installs; consider disabling install scripts

No required checks

Insecure code merges because nothing blocks it

Make security checks required with branch rulesets

How do you harden GitHub Actions?

GitHub's secure use reference for Actions is the primary source. The core steps:

1. Set least-privilege permissions. Declare permissions explicitly so GITHUB_TOKEN gets only what each job needs:

permissions:
  contents: read
permissions:
  contents: read
permissions:
  contents: read

Grant write scopes (such as pull-requests: write) only on the specific job that needs them.

2. Pin actions to a full commit SHA. Tags are mutable; a SHA isn't:

- uses: actions/checkout@<full-40-character-commit-sha>
- uses: actions/checkout@<full-40-character-commit-sha>
- uses: actions/checkout@<full-40-character-commit-sha>

Keep the version in a comment so updates stay readable, and let a dependency bot propose SHA bumps.

3. Scope secrets. Put deployment secrets in protected environments with required reviewers, prefer short-lived OIDC credentials to long-lived cloud keys, and never echo secrets.

4. Treat pull_request_target as dangerous. It runs with your secrets in the context of the base repository. Don't check out and execute code from the pull request in it.

5. Watch the build's dependencies. Lockfiles, verified registries and dependency scanning keep a malicious package from running in CI. npm's move to disable install scripts by default in npm 12 shows how central this has become; see also how to detect malicious npm packages.

6. Measure your posture. OpenSSF Scorecard checks a repository for token permissions, pinned dependencies and branch protection, and SLSA describes the build-integrity levels to aim for.

How do you stop vulnerable code from shipping through the pipeline?

Add a security gate to the merge, so the pipeline enforces that code, dependencies and secrets pass before anything reaches the main branch. With GitHub rulesets, mark the security check as required on your default branch, apply the ruleset across every repository in the organization, and limit who can bypass it.

This is where a pull request security reviewer becomes a pipeline control. ARGUS reviews each pull request for vulnerable dependencies, hardcoded secrets, insecure code and infrastructure-as-code misconfigurations, ranks by reachability, and posts a required check, so an exploitable change waits while ARGUS opens the fix as a pull request. ARGUS also checks the workflow files themselves: it matches the actions you use against known advisories, flags any action not pinned to a full commit SHA, and reads runtime versions from actions/setup-* steps to flag end-of-life Node, Python, Java and other toolchains. Token scoping, branch rules and environment protection stay configuration tasks on your side; see how to secure a GitHub repository. See how ARGUS reviews a pull request.

Frequently asked questions

Why pin GitHub Actions to a commit SHA?

Because tags are mutable. If an action's maintainer, or an attacker who compromised them, moves a tag to malicious code, every pipeline referencing that tag runs it. A full commit SHA can't change under you.

What permissions should GITHUB_TOKEN have?

The minimum each job needs. Start with contents: read at the workflow level and grant specific write permissions only on the jobs that need them.

What is a merge gate?

A required check that blocks a pull request from merging unless it passes, for example a security review that fails on an exploitable vulnerability or a committed secret.

Is CI/CD security part of supply chain security?

Yes. The pipeline builds and ships your software, so compromising it is a direct supply-chain attack, which is why frameworks like SLSA focus on build integrity.

Our read

The CI/CD pipeline is the most privileged, least-watched part of many startups' stacks, which is exactly why attackers aim at it. Hardening the workflow closes the configuration gaps, but the durable win is making the pipeline enforce security on the code itself through a required check that blocks exploitable changes and fixes them in place.

Related reading: How to find hardcoded secrets in code · SBOM for startups · CTO guide to securing a startup codebase

DATA SOURCES

OWASP Top 10 CI/CD Security Risks: https://owasp.org/www-project-top-10-ci-cd-security-risks/ ; GitHub Actions security hardening: https://docs.github.com/actions/security-guides/security-hardening-for-github-actions ; SLSA supply-chain framework: https://slsa.dev/

Liked this post? Share it:

Related posts