BERRY9 IT SERVICES

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

CI/CD Pipeline Security: GitHub Actions & GitLab Runners architecture and testing overview

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.2

Four Workflow Flaws That Leak Repo Secrets

Top CI/CD pipeline vulnerabilities tested in DevSecOps reviews
CI/CD RiskHow Exploitation HappensFix
pull_request_target InjectionWorkflow checks out untrusted PR code with access to repo secretsNever checkout PR head inside pull_request_target; use pull_request
Expression Injection${{ github.event.issue.title }} interpolated inside run: shellPass untrusted event fields via env: variables, never inline
Unpinned Actionsuses: vendor/action@v2 can be hijacked if tag is movedPin third-party actions to full 40-char commit SHAs
Self-Hosted RunnersPublic or shared runners persist Docker/filesystem across jobsUse 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.