Insufficient Pipeline-Based Access Controls

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

Insufficient Pipeline-Based Access Controls — Training Steps

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

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

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

  4. Read the customer table

    This is the production store database. From a pull-request job, Bob reads the customer table directly.

  5. Why the test job could reach production

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

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

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

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

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