Security Playbook
24 · Cloud & supply chainOWASP A03:20256 min read

CI/CD security: your pipeline holds the keys

Pipelines run code from pull requests, pull third-party actions and hold credentials for production. That makes them one of the most valuable targets you own. The settings that keep a stranger's PR from becoming a deploy.

In one sentence

Treat PRs from forks as untrusted code, pin actions to a commit SHA, use OIDC instead of stored cloud keys, and gate deploys behind protected branches and reviewers.

What can a pull request reach?

A pull request from a stranger: what can it reach in CI?
01PR from a fork changes the test script to print env vars✕ Exposed
02A third-party action used in the workflow gets a malicious new tag✕ Exposed
03The workflow holds a long-lived AWS key with admin rights✕ Exposed
04The same job can deploy to production✕ Exposed

A stranger's PR can steal secrets and ship code to production.

CI/CD is a production system with the keys to everything. Treat untrusted PRs as untrusted code, pin actions, prefer OIDC over stored keys and separate build from deploy.
Each control closes one path from an untrusted PR to your secrets or to production.

Pipeline hardening checklist

  • Fork PRs get no secrets. Be careful with pull_request_target and similar triggers that run with secrets on untrusted code.
  • Pin third-party actions to a full commit SHA, not a tag that can be moved.
  • OIDC federation to your cloud: the job gets a short-lived role scoped to that repo and branch; nothing to leak.
  • Least-privilege tokens: the default GITHUB_TOKEN read-only, write permissions only where a job needs them.
  • Separate build and deploy; deploy only from protected branches with required reviews and environment approvals.
  • Signed artifacts / provenance (e.g. SLSA, Sigstore) so production only runs what your pipeline built.
permissions:
  contents: read
  id-token: write   # OIDC, no stored AWS keys
steps:
  - uses: actions/checkout@<full-commit-sha>
  - uses: aws-actions/configure-aws-credentials@<full-commit-sha>
    with:
      role-to-assume: arn:aws:iam::123456789012:role/deploy-web-main

Key takeaways

  • 01CI/CD is production infrastructure with access to everything.
  • 02Never expose secrets to workflows running untrusted PR code.
  • 03Pin actions to SHAs and prefer OIDC over stored keys.
  • 04Deploy only from protected branches with approvals.

Check your understanding

1 of 3

How should pull requests from forks be treated?

Related concepts