CI/CD Pipeline Security: GitHub Actions & GitLab Runners
Securing GitHub Actions and GitLab CI/CD pipelines: pull_request_target injection, self-hosted runner escapes, unpinned actions, and OIDC cloud roles.
DevSecOps · By Thimmagurudu Bathini, CTO · Published · 6 min read
Why Compromising CI/CD Bypasses App Security
Your CI/CD pipeline holds production cloud deploy keys, container registry credentials, and signing certificates. A single misconfigured pull_request_target workflow or shared self-hosted runner can let an external pull request exfiltrate production secrets or backdoor your release artifacts.
permissions:
contents: read
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2Four Workflow Flaws That Leak Repo Secrets
| CI/CD Risk | How Exploitation Happens | Fix |
|---|---|---|
| pull_request_target Injection | Workflow checks out untrusted PR code with access to repo secrets | Never checkout PR head inside pull_request_target; use pull_request |
| Expression Injection | ${{ github.event.issue.title }} interpolated inside run: shell | Pass untrusted event fields via env: variables, never inline |
| Unpinned Actions | uses: vendor/action@v2 can be hijacked if tag is moved | Pin third-party actions to full 40-char commit SHAs |
| Self-Hosted Runners | Public or shared runners persist Docker/filesystem across jobs | Use ephemeral auto-scaling runners isolated per trust boundary |
Auditing PR Triggers, Runners & Token Scopes
- Audit all .github/workflows/*.yml and .gitlab-ci.yml files for pull_request_target and inline expression interpolation.
- Verify third-party GitHub Actions are pinned to immutable commit SHAs and reviewed via Dependabot.
- Check runner permissions (GITHUB_TOKEN permissions: read-all by default) and branch protection rules.
- Replace long-lived AWS/GCP/Azure deploy secrets with short-lived OIDC federation.
Moving From Static Keys to OIDC Federation
Set default GITHUB_TOKEN permissions to read-only, migrate cloud deployments to OIDC, and isolate production deployment runners from untrusted PR builds.
Include GitHub Actions or GitLab CI auditing in a DevSecOps review from ₹36,000 + 18% GST. Request a scoped proposal →
CI/CD Security Testing Questions
Why do security teams audit CI/CD pipelines separately from web apps?
Because compromising CI/CD lets an attacker inject malicious code directly into signed production builds and bypass app-level defenses.
Do you check private repositories safely?
Yes—reviews run under Mutual NDA with read-only repository access.