Over-Privileged CI/CD Pipeline Credentials
Build and deployment pipelines run with credentials far broader than their tasks need, so any compromise of a pipeline gives wide control of cloud, code and production systems.
| Severity | High |
| CVSS 3.1 | 7.5 CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H Open in the calculator |
| CVSS 4.0 | 7.7 CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N Open in the calculator |
| CWE | CWE-250: Execution with Unnecessary Privileges |
| MITRE ATT&CK | T1078.004 Cloud Accounts, T1195.002 Compromise Software Supply Chain |
| Category | Broken Access Control |
Description
The credentials that a CI/CD pipeline uses grant far more access than the pipeline's tasks need. Typical examples are a cloud service principal or IAM role with owner or administrator rights over a whole subscription or account; one deployment credential shared by development, test and production; a repository token with write access to every repository in the organisation; a workflow token with broader write permissions than the job uses; Kubernetes service accounts bound to cluster-admin; and self-hosted runners shared between projects of different trust levels, or that keep credentials and files between jobs.
Over-privilege does not give an attacker access by itself, and the attacker still needs a way into the pipeline first, whether through injection into a workflow, a malicious or compromised dependency or build tool, a stolen developer account or exposed pipeline secrets. Because pipelines run code from many sources automatically, they are a common target, and the privileges decide how much damage follows from any such compromise.
An attacker who can run code in, or steal credentials from, an over-privileged pipeline gains everything those credentials allow rather than only what the job needed. That can include administrative control of cloud accounts, read and write access to every repository, the ability to publish packages and container images, and direct access to production systems and data, while persistent runners shared between projects let a compromise of one low-value project reach the secrets and builds of others. Once inside, the excess privileges turn a contained incident into an organisation-wide one.
The weakness is identified by reviewing the roles and permissions assigned to pipeline identities, service connections and tokens, the scope of deployment credentials for each environment and the runner configuration, and by comparing them with what each job actually does.
Remediation
Apply least privilege to every identity and credential a pipeline uses:
- Give each pipeline, and where possible each job, its own identity scoped to the specific resources it deploys to, with separate credentials for each environment, and remove owner, administrator and wildcard permissions.
- Replace long-lived keys with short-lived credentials issued through OpenID Connect federation, with trust conditions that limit them to specific repositories, branches and environments.
- Set workflow token permissions to read-only by default at organisation or repository level, and grant write scopes explicitly in the jobs that need them.
- Protect production deployments with environment protection rules or approval gates, so that only reviewed code from protected branches can use production credentials.
- Use ephemeral, single-use runners where possible, keep self-hosted runners separate for different trust levels, and do not leave cloud credentials on runner hosts.
- Review pipeline identities regularly, using the cloud provider's access analysis tools to remove permissions that are never used.
Confirm the fix by listing the effective permissions of each pipeline identity and token, and checking that they match the documented needs of the jobs that use them.
References
Add This Finding to Your Library
In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.
Free trialYour trial starts when your portal goes live, not when you sign up, so the time you spend setting up does not count. · No card required
Only need the reporting? Our reporting tool is free and open source, with the same library.