📋 What Is It?
Pipeline-Based Access Controls (PBAC) are the permissions granted to the environment a pipeline runs in - the runner or agent and the identity, secrets, and network reach it carries during a job. Insufficient PBAC is when that execution environment holds access far beyond what the specific job needs: a compile step that can read every org secret, assume a wildcard cloud role, reach the production control plane, and leave artefacts for the next job on the same machine. Because a pipeline is a programmable execution surface, the runner's privileges become the job's privileges - whatever code lands there inherits them.
⚠️ Common Exploits
- All Secrets in Every Job: A compile step can read the production deploy key it never needed
- Standing Broad Cloud Role: A wildcard IAM role on the runner = one build compromises the account
- Non-Ephemeral Runners: Leftover creds, caches, and workspaces harvested by the next job
- Shared Runners Across Trust: Fork PRs run on the same pool as production-credentialed pipelines
- Control-Plane Reach: Build jobs can hit the metadata service, k8s API, or prod DB
- Cache / Artifact Poisoning: Low-trust jobs write what high-trust jobs consume unverified
- Runner Implants: Trojaned toolchain on a reused runner hits every later job
- Container Escape: Mounted Docker socket / privileged container reaches the host
🔴 Attack Flow
↓
2. Enumerate the runner's access (env, ~/.aws, metadata, network)
↓
3. Abuse standing privilege (read all secrets, assume broad role)
↓
4. Reach systems the build should never touch (prod, control plane)
↓
5. IMPACT: Cloud-account takeover, no application bug required!
❌ Vulnerable Code
✅ Secure Code
✓ Prevention Checklist
- Inject only the secrets a job actually needs - never all
- Use ephemeral, single-use runners; destroy after each job
- Never share a runner pool between public and private repos
- Replace standing broad roles with per-job scoped OIDC tokens
- Segment runner network from prod, metadata, and control plane
- Split build from deploy across separately scoped runners
- Set explicit least-privilege token permissions (read by default)
- Mark deploy secrets protected + masked, branch-scoped
- Verify integrity of caches and artifacts across trust levels
- Never let build jobs run on the CI controller / host
🔍 Detection & Tools
Least-Privilege & Isolation:
Policy & Audit:
How to Test:
- Check whether a build job can read secrets it never uses
- Query the metadata endpoint from a job - should be blocked
- Confirm runners are ephemeral and torn down after jobs
- Verify fork PRs cannot reach private/self-hosted runners
- Audit runner IAM roles for wildcard actions/resources
- Test that a build runner cannot reach prod / the k8s API
🌍 Real-World (Incident Classes)
- PPE on Over-Privileged Runners: Public repos ran PR-triggered pipelines on self-hosted runners holding production secrets and broad cloud roles; a crafted PR modified a build/test step to encode and exfiltrate the environment - the classic Poisoned Pipeline Execution outcome amplified by the runner's standing access.
- Non-Ephemeral Runner Reuse: Long-lived self-hosted runners retained cloud credentials, registry logins, and kubeconfigs on disk; a later low-trust (fork) job landed on the same host and read the leftover state, inheriting access it was never granted.
- Shared Cache / Artifact Poisoning: A cache or artifact store writable by low-trust jobs was consumed unverified by higher-trust deploy pipelines, so malicious content written once propagated into signed, shipped artefacts.
- Cross-Trust Shared Runner Pool: Untrusted fork code executed on a runner that also served a private, production-credentialed pipeline, exposing another project's secrets and runner config.
📌 Quick Tips
- DO NOT inject all secrets into every job
- DO NOT attach standing wildcard roles to runners
- DO NOT share runners across trust boundaries
- DO use ephemeral, single-use runners
- DO scope short-lived OIDC per job
- DO segment build runners from production
- DO split build and deploy responsibilities
📜 Compliance
Related Standards:
- SLSA Build L3 - Isolated, Ephemeral
- NIST 800-53 AC-6 - Least Privilege
- NIST SSDF PO.5 - Secure Build Environments
- ISO 27001 A.9 - Access Control
- CIS Software Supply Chain Benchmark