Insufficient Pipeline-Based Access Controls
A repository secret is in every job, including a stranger's pull request.
What Is Insufficient Pipeline-Based Access Controls?
A secret attached to a repository is in the environment of every job in that repository, including the job that runs on a stranger's pull request. You'll watch a routine pull-request test job reach the production database with a repo-scoped credential and read the customer table, then fix it by scoping the secret to a protected environment, keeping production credentials out of pull-request jobs, and rotating the one that was exposed.
What You'll Learn in Insufficient Pipeline-Based Access Controls
- A secret scoped to a repository is in the environment of every job there, including a job that runs on an untrusted pull request.
- This is a scope problem, not an execution one: a legitimate test job simply held a production credential and could use it.
- Scope production credentials to a protected environment released only to approved deploy jobs, and keep them out of pull-request contexts.
- Give each stage its own least-privilege credential, and rotate any secret a pull-request job was able to reach.
Insufficient Pipeline-Based Access Controls — Training Steps
-
A secret the whole repo can read
Varthen keeps the production database credential in CI as a repository secret. That means it is in the environment of every job in the repo, and Bob's pull request runs a job in that repo, the same as anyone's. His job is a legitimate test suite. He does not need to break it or hide anything in it. He just needs to look at what is already in its environment.
-
Scoped to the repository
The production database credential is scoped to the repository. Nothing about that scope distinguishes a trusted deploy job from a pull-request test job: both are jobs in this repo, so both get the secret.
-
Use it from the test job
From inside his pull-request's test job, Bob connects to the production database with the credential that was sitting in the environment. Nothing is exfiltrated; the secret is simply used from where it already was.
-
Read the customer table
This is the production store database. From a pull-request job, Bob reads the customer table directly.
-
Why the test job could reach production
-
Production read from a PR runner
Varthen's database monitoring flagged a read of the production customer table from a pull-request runner, using the pipeline's own credential.
-
Confirm the scope
Alice opens the CI secret settings. The production credential is scoped to the repository, which is why a pull-request job could hold it.
-
Where the job gets it
Because the secret is repository-scoped, the test job pulls it straight into its environment. Alice opens the workflow to see the pull-request job carrying the production credential.
-
Keep production out of PR jobs
The test job has no business touching production. Alice points it at a disposable test database and leaves the production credential to a protected environment the pull-request job cannot reach.
-
Read the hardened job
The pull-request job now uses a throwaway test database. The production credential is no longer anywhere in its environment.
Security Framework Coverage
OWASP CI/CD Top 10
- CICD-SEC-5 Insufficient PBAC (Pipeline-Based Access Controls)
CWE
- CWE-250 Execution with Unnecessary Privileges
- CWE-668 Exposure of Resource to Wrong Sphere
MITRE ATT&CK
- T1552 Unsecured Credentials
CIS Controls
- CIS 6 Access Control Management
- CIS 16 Application Software Security
NIST CSF
- PR.AT-02 Individuals in specialized roles are provided with awareness and training so that they possess the knowledge and skills to perform relevant tasks with cybersecurity risks in mind
- PR.AA Identity Management, Authentication, and Access Control
- PR.PS Platform Security
NICE Framework
- DD-WRL-004 Secure Systems Development
- IO-WRL-005 Systems Administration