Common Threat Matrix for CI/CD Pipeline
This is an ATT&CK-like matrix focus on CI/CD Pipeline specific risk.
MITRE ATT&CK® is a knowledge base of adversary tactics and techniques.
To map the threat of CI/CD Pipeline, I use the same classification as the framework.
(Feedback is welcome)
Table of Contents
Background
This threat map is published in conjunction to the presentation “Attacking and Securing CI/CD Pipeline” at CODE BLUE 2021 Opentalks.
The purpose of this matrix is to share knowledge on securing CI/CD environments with Cybersecurity community.
This matrix was created by Mercari Security Team, and reviewed by Platform Team.
Threat Matrix
Components of CI/CD
Name | Tools |
---|---|
Device | - Developer Workstation: Mac/Win/Cloud-based |
Git Repository Service | - GitHub, GitLab |
CI | - CI/CD Services (e.g. CircleCI, Cloud Build, Codebuild, GitHub Actions) |
CD | - CI/CD Services (e.g. CircleCI, Cloud Build, Codebuild, GitHub Actions) - CD Services (e.g. Spinnaker, ArgoCD) |
Secret Management | - Secret Management Services (e.g. AWS Secret Manager, GCP Secret Manager, HashiCorp Vault) |
Production environment | - Cloud Services (e.g AWS, Google Cloud, Microsoft Azure) - Other Resources (e.g. Container Registry, Linux Server, Kubernetes) |
Techniques and Mitigation
Initial Access
Techniques | Description | Mitigation |
Supply Chain Compromise on CI/CD | Supply Chain Attacks to Application Library, Tools, Container Images in CI/CD Pipelines. |
|
Valid Account of Git Repository
(Personal Token, SSH key, Login password, Browser Cookie) |
Use developer’s credentials to access to Git Repository Service \ (Personal token, SSH key, browser cookie, or login password is stolen) |
|
Valid Account of CI/CD Service
(Personal Token, Login password, Browser Cookie) |
Use SSH key or Tokens to access to CI/CD Service Servers directly |
|
Valid Admin account of Server hosting Git Repository | Use SSH key, Tokens to access to Server hosting Git Repository |
|
Execution
Techniques | Description | Mitigation |
Modify CI/CD Configuration | Modify CI/CD Configuration on Git Repository
(CircleCI: .circleci/config.yml, CodeBuild: buildspec.yml, CloudBuild: cloudbuild.yaml, GitHub Actions: .github/workflows/*.yaml) |
|
Inject code to IaC configuration | For example, Terraform allows code execution and file inclusion. The code is executed during CI(plan stage)
Code Execution: Provider installation(put provider binary with .tf), Use External provider |
|
Inject code to source code | Application executes test code during CI |
|
Supply Chain Compromise on CI/CD | (Repeated) | |
Inject bad dependency | Inject bad dependency |
|
SSH to CI/CD pipelines | Connect to CI/CD pipeline servers via SSH or Valid Token |
|
Execution (Production)
Techniques | Description | Mitigation |
Modify the configuration of Production environment | Modify the configuration of Production environment via stolen credentials |
|
Deploy modified applications or server images to production environment | Deploy modified applications or server images (e.g. container image, function, VM image) to production environment via stolen credentials |
|
Persistence
Techniques | Description | Mitigation |
Compromise CI/CD Server | Compromise CI/CD Server from pipeline |
|
Implant CI/CD runner images | Implant container images for CI/CD with malicious code to establish persistence |
|
(Modify CI/CD Configuration) | (Repeated) | |
(Inject code to IaC configuration) | (Repeated) | |
(Inject code to source code) | (Repeated) | |
(Inject bad dependency) | (Repeated) |
Privilege Escalation
Techniques | Description | Mitigation |
Get credential for Deployment(CD) on CI stage | Get high privilege credential in CI stage (not CD) |
|
Privileged Escalation and compromise other CI/CD pipeline | Privilege Escalation from CI/CD Environment to other components |
|
Defense Evasion
Techniques | Description | Mitigation |
Add Approver using Admin permission | Change Approver using Git Repository Service Admin permission |
|
Bypass Review | Bypass Peer Review of Git Repository |
|
Access to Secret Manager from CI/CD kicked by different repository | Use a CI/CD system in a different repository to leverage stolen credentials to access secret manager |
|
Modify Caches of CI/CD | Implant bad code to caches of CI/CD pipeline |
|
Implant CI/CD runner images | (Repeated) |
Credential Access
Techniques | Description | Mitigation |
Dumping Env Variables in CI/CD | Dump Environment Variables in CI/CD |
|
Access to Cloud Metadata | Access to Cloud Metadata to get access token of Cloud resources |
|
Read credentials file | Read credentials file mounted in CI/CD pipeline |
|
Get credential from CI/CD Admin Console | See credential from CI/CD admin console |
|
Lateral Movement
Techniques | Description | Mitigation |
Exploitation of Remote Services | Exploit services from CI/CD Pipeline |
|
(Monorepo) Get credential of different folder's context | In monorepo architecture of Git Repository, there are many approvers.
Need to set access controls carefully |
|
Privileged Escalation and compromise other CI/CD pipeline
(Repeated) |
Exfiltration
Techniques | Description | Mitigation |
Exfiltrate data in Production environment | Exfiltrate data in Production environment via stolen credentials |
|
Clone Git Repositories | Exfiltrate data from Git Repositories |
|
Impact
Techniques | Description | Mitigation |
Denial of Services | Denial of Services of CI/CD pipeline |
|
Common Question
Supply-chain attacks are the only risk of CI/CD pipeline, correct?
Supply-chain attacks are one of the most serious risks. But it is not the only risk for CI/CD Pipelines. The entire attack surface need to be considered. You can check my slide: “Attacking and Securing CI/CD Pipeline” to know risks of CI/CD pipeline