Security¶
Risks¶
CI/CD is the automation of most (if not all) process in your software lifecycle going from building to running the application in production. With so many things happening, attackers have a wide range of capabilities in case of a compromise:
- introduce dubious components (i.e. backdoor) in the application,
- leak (to the Internet) credentials granting access to internal services or infrastructures,
- access said services or infrastructures,
- impersonate an employee,
- leak intellectual property,
- ...
Every CI/CD job is executed inside a container image which contains various tools required by the job. When you are executing the job, you are trusting the people building the image and the tools.
In some cases, the image may have been corrupted by an attacker. This is what we call a supply chain attack. There are famous cases like the Codecov incident in which hackers managed to leak credentials from several services and cloud platforms.
Mitigations¶
Variables scoping¶
To prevent leakage, CI/CD variables has to be present only in jobs that need them. By example in the Maven template, only the mvn-sonar job actually needs the SONAR_TOKEN environment variable so others jobs (mvn-build, mvn-release...) should not access this secret.
You can find more info about how to protect your CI/CD variables in the official GitLab documentation.
Image selection¶
As much as we can, we try to select either official images (ex: Maven, Python), or at least images maintained by an active community. Each of those images can be freely overridden with the appropriate configuration variable to select fixed versions (more info here) or any alternative that would suit you more.
By default, to be continuous templates mostly use the latest tag from upstream images since it is a maintenance-less default that works for nearly everyone. However latest images are prone to supply chain attacks and are also likely to introduce breaking changes.
to be continuous is not responsible of any possible security issue from a default container image.
To mitigate the risks of using latest images, you should always use a fixed version tag (maven:3.9.1 instead of maven:latest) or build your own image.
Additional dependencies¶
However, the direct counterpart of using official images is that many default image do not ship all the required tools used by the template (think about git and curl utilities). For this reason, many templates check the presence of these additional dependencies and install them on the fly (see maybe_install_pkg function).
This is a good practice to avoid bloating the image with unnecessary tools, but it also means that you are trusting the upstream repositories of your distribution (i.e. Debian, Alpine, etc.) to not be compromised and requiring network access to download packages.
Every project is encouraged to maintain his own Docker image in order to fit to their needs, avoid extraneous downloading for additional dependencies and simplify the work of security team (it's easy to scan a Docker image). While doing so, we recommend to use a minimal distribution and root-less images to prevent some container escalation vulnerabilities against your runner provider.
Tip
Whenever building your own image or using an upstream image, you can use Renovate to watch updates for your tools, test the new version and integrate them seamlessly.
Vulnerability Reports (Trivy)¶
Important
When reviewing vulnerabilities from containers, you have to consider the following principes :
- containers are usually very short-lived in a CI/CD environment
- no direct user access is possible
- most job does not expose any exteral services (i.e. HTTP server) making attacks reliant on user interaction very hard if not impossible to exploit
In short, risks are often low in the CI/CD context but carefully reviewing vulnerabilities are an essential step to secure your pipeline.
Here are vulnerability reports for each default image used by to be continuous templates (generated every day):
| Template | Image Variable | Default Image | Vulnerabilities |
|---|---|---|---|
| Ansible | ANSIBLE_IMAGE | docker.io/cytopia/ansible:latest-tools |
5 High, 21 Medium, 1 Low, 2 Unknown |
| Ansible | ANSIBLE_LINT_IMAGE | docker.io/haxorof/ansible-lint:latest |
|
| Amazon Web Services | AWS_CLI_IMAGE | docker.io/amazon/aws-cli:latest |
1 High, 2 Medium, 2 Low |
| Azure | AZURE_CLI_IMAGE | mcr.microsoft.com/azure-cli:latest |
2 High |
| Bash | BASH_BATS_IMAGE | docker.io/bats/bats:latest |
3 Medium, 3 Low |
| Bash | BASH_SHELLCHECK_IMAGE | docker.io/koalaman/shellcheck-alpine:stable |
7 Medium, 5 Low |
| Bruno | BRU_IMAGE | docker.io/library/node:lts-alpine |
2 High, 1 Medium |
| GitLab Butler | BUTLER_IMAGE | registry.gitlab.com/to-be-continuous/tools/gitlab-butler:latest |
2 High, 4 Medium, 3 Low |
| Cloud Foundry | CF_CLI_IMAGE | docker.io/governmentpaas/cf-cli |
6 Critical, 40 High, 96 Medium, 3 Low, 2 Unknown |
| Cloud Native Buildpacks | CNB_BUILDER_IMAGE | docker.io/paketobuildpacks/builder-jammy-base:latest |
4 Critical, 307 High, 1916 Medium, 142 Low |
| Cloud Native Buildpacks | CNB_SKOPEO_IMAGE | quay.io/containers/skopeo:latest |
|
| Cloud Native Buildpacks | CNB_TRIVY_IMAGE | docker.io/aquasec/trivy:latest |
2 High, 8 Medium, 5 Low |
| Cypress | CYPRESS_IMAGE | docker.io/cypress/included:13.13.3 |
30 Critical, 187 High, 385 Medium, 326 Low, 31 Unknown |
| dbt | DBT_IMAGE | ghcr.io/dbt-labs/dbt-core:latest |
4 Critical, 395 High, 1503 Medium, 677 Low, 40 Unknown |
| Docker Compose | DCMP_IMAGE | docker.io/library/docker:latest |
4 High, 8 Medium |
| Docker Compose | DCMP_KICS_IMAGE | docker.io/checkmarx/kics:latest |
1 High, 1 Medium |
| Debian | DEBIAN_BASE_IMAGE | docker.io/debian |
10 Medium, 50 Low |
| Debian | DEBIAN_BUILD_IMAGE | $DEBIAN_BASE_IMAGE |
not fetched |
| Debian | DEBIAN_LINT_IMAGE | $DEBIAN_BASE_IMAGE |
not fetched |
| DefectDojo | DEFECTDOJO_BASE_IMAGE | docker.io/library/node:alpine3.11 |
1 Critical, 25 High, 3 Medium, 2 Low |
| Dependency Track | DEPTRACK_SBOM_SCANNER_IMAGE | registry.gitlab.com/to-be-continuous/tools/dt-sbom-scanner:latest |
1 Critical, 2 High, 11 Medium, 5 Low |
| Docker | DOCKER_BUILDAH_IMAGE | quay.io/containers/buildah:latest |
|
| Docker | DOCKER_DIND_IMAGE | docker.io/library/docker:dind |
4 High, 8 Medium |
| Docker | DOCKER_HADOLINT_IMAGE | docker.io/hadolint/hadolint:latest-alpine |
7 Medium, 5 Low |
| Docker | DOCKER_IMAGE | docker.io/library/docker:latest |
4 High, 8 Medium |
| Docker | DOCKER_KANIKO_IMAGE | gcr.io/kaniko-project/executor:debug |
36 High, 65 Medium |
| Docker | DOCKER_SBOM_IMAGE | docker.io/anchore/syft:debug |
1 High, 3 Medium |
| Docker | DOCKER_SKOPEO_IMAGE | quay.io/containers/skopeo:latest |
|
| Docker | DOCKER_TRIVY_IMAGE | docker.io/aquasec/trivy:latest |
2 High, 8 Medium, 5 Low |
| .NET | DOTNET_IMAGE | mcr.microsoft.com/dotnet/sdk:10.0 |
8 Medium, 17 Low |
| .NET | DOTNET_SBOM_IMAGE | ghcr.io/cyclonedx/cdxgen:master |
24 High, 32 Medium, 1 Unknown |
| Google Cloud | GCP_CLI_IMAGE | gcr.io/google.com/cloudsdktool/cloud-sdk:latest |
4 Critical, 175 High, 628 Medium, 624 Low, 29 Unknown |
| Gitleaks | GITLEAKS_IMAGE | docker.io/zricethezav/gitleaks:latest |
1 High, 14 Medium, 3 Low |
| GitOps | GITOPS_IMAGE | docker.io/alpine/git:latest |
17 Medium, 3 Low |
| GitLab Package | GLPKG_IMAGE | docker.io/curlimages/curl:latest |
3 Medium, 3 Low |
| Go | GO_CI_LINT_IMAGE | docker.io/golangci/golangci-lint:latest-alpine |
1 High, 1 Medium |
| Go | GO_IMAGE | docker.io/library/golang:bookworm |
2 Critical, 160 High, 589 Medium, 496 Low, 26 Unknown |
| Go | GO_SBOM_IMAGE | $GO_IMAGE |
not fetched |
| Go | GO_SEMGREP_IMAGE | docker.io/semgrep/semgrep:latest |
3 High, 2 Medium |
| Gradle | GRADLE_IMAGE | docker.io/library/gradle:latest |
94 Medium, 32 Low |
| Helmfile | HELMFILE_CLI_IMAGE | ghcr.io/helmfile/helmfile:latest |
2 Critical, 42 High, 100 Medium, 4 Low |
| Helm | HELM_CLI_IMAGE | docker.io/alpine/helm:latest |
1 High, 6 Medium, 3 Low |
| Helm | HELM_KUBE_SCORE_IMAGE | docker.io/zegl/kube-score |
8 Critical, 70 High, 106 Medium, 3 Low |
| Helm | HELM_YAMLLINT_IMAGE | docker.io/cytopia/yamllint |
7 High, 13 Medium, 2 Unknown |
| Hurl | HURL_IMAGE | ghcr.io/orange-opensource/hurl:latest |
3 Medium, 3 Low |
| k6 | K6_IMAGE | docker.io/grafana/k6:latest |
1 High, 6 Medium, 3 Low |
| Kubernetes | K8S_KUBECTL_IMAGE | docker.io/alpine/k8s:MUST_SET_VERSION |
not fetched |
| Kubernetes | K8S_KUBE_SCORE_IMAGE | docker.io/zegl/kube-score:latest |
8 Critical, 70 High, 106 Medium, 3 Low |
| Lighthouse | LHCI_IMAGE | docker.io/cypress/browsers:latest |
9 High, 50 Medium, 198 Low, 3 Unknown |
| GNU Make | MAKE_IMAGE | docker.io/alpinelinux/build-base |
|
| Maven | MAVEN_IMAGE | docker.io/library/maven:latest |
80 Medium, 32 Low |
| MkDocs | MKD_IMAGE | docker.io/squidfunk/mkdocs-material:latest |
8 High, 7 Medium, 3 Low |
| MkDocs | MKD_LYCHEE_IMAGE | docker.io/lycheeverse/lychee:latest |
1 Critical, 4 High, 20 Medium, 60 Low, 1 Unknown |
| MobSF | MOBSF_CLIENT_IMAGE | docker.io/badouralix/curl-jq |
3 Medium, 3 Low |
| MobSF | MOBSF_CODE_IMAGE | docker.io/opensecurity/mobsfscan:latest |
6 Critical, 451 High, 1431 Medium, 500 Low, 25 Unknown |
| Angular | NG_CLI_IMAGE | docker.io/trion/ng-cli-karma:latest |
2 Critical, 175 High, 601 Medium, 612 Low, 26 Unknown |
| Node.js | NODE_IMAGE | docker.io/library/node:lts-alpine |
2 High, 1 Medium |
| Node.js | NODE_SEMGREP_IMAGE | docker.io/semgrep/semgrep:latest |
3 High, 2 Medium |
| OSS Review Toolkit (ORT) | ORT_SCANNER_IMAGE | ghcr.io/oss-review-toolkit/ort:latest |
13 Critical, 114 High, 1479 Medium, 167 Low, 1 Unknown |
| OpenShift | OS_CLI_IMAGE | quay.io/openshift/origin-cli:latest |
19 High, 71 Medium, 183 Low |
| PHP | PHP_IMAGE | docker.io/library/php:latest |
61 High, 141 Medium, 421 Low, 22 Unknown |
| Playwright | PLAYWRIGHT_IMAGE | mcr.microsoft.com/playwright:latest |
6 High, 769 Medium, 149 Low |
| Postman | POSTMAN_IMAGE | docker.io/postman/newman:latest |
8 High, 31 Medium, 8 Low, 2 Unknown |
| pre-commit | PRE_COMMIT_IMAGE | docker.io/library/python:3-alpine |
|
| Puppeteer | PUPPETEER_IMAGE | ghcr.io/puppeteer/puppeteer:latest |
7 Critical, 206 High, 639 Medium, 804 Low, 26 Unknown |
| Python | PYTHON_IMAGE | docker.io/library/python:3-slim |
10 Medium, 51 Low |
| Renovate | RENOVATE_IMAGE | docker.io/renovate/renovate:latest |
3 High, 1116 Medium, 78 Low |
| Robot Framework | ROBOT_BASE_IMAGE | docker.io/ppodgorsek/robot-framework:latest |
3 High |
| RPM | RPM_BASE_IMAGE | docker.io/fedora |
|
| RPM | RPM_BUILD_IMAGE | $RPM_BASE_IMAGE |
not fetched |
| RPM | RPM_LINT_IMAGE | $RPM_BASE_IMAGE |
not fetched |
| Rust | RUST_IMAGE | docker.io/library/rust:latest |
92 High, 201 Medium, 696 Low, 29 Unknown |
| Source-to-Image | S2I_DIND_IMAGE | docker.io/library/docker:dind |
4 High, 8 Medium |
| Source-to-Image | S2I_SKOPEO_IMAGE | quay.io/containers/skopeo:latest |
|
| Source-to-Image | S2I_TRIVY_IMAGE | docker.io/aquasec/trivy:latest |
2 High, 8 Medium, 5 Low |
| S3 (Simple Storage Service) | S3_CMD_IMAGE | docker.io/d3fk/s3cmd:latest |
2 High, 5 Medium, 3 Low, 1 Unknown |
| Scala/SBT | SBT_IMAGE | docker.io/sbtscala/scala-sbt:17.0.2_1.6.2_3.1.3 |
53 Critical, 238 High, 352 Medium, 695 Low, 14 Unknown |
| Scala/SBT | SBT_SBOM_IMAGE | docker.io/anchore/syft:debug |
1 High, 3 Medium |
| semantic-release | SEMREL_IMAGE | docker.io/library/node:lts-slim |
1 Critical, 6 High, 21 Medium, 58 Low, 1 Unknown |
| SonarQube | SONAR_SCANNER_IMAGE | docker.io/sonarsource/sonar-scanner-cli:latest |
5 High, 2 Medium, 2 Low |
| Spectral | SPECTRAL_IMAGE | docker.io/stoplight/spectral:latest |
6 High, 29 Medium, 8 Low, 2 Unknown |
| Sphinx | SPHINX_IMAGE | ghcr.io/sphinx-doc/sphinx:latest |
24 Critical, 62 High, 62 Medium, 183 Low, 2 Unknown |
| Sphinx | SPHINX_LYCHEE_IMAGE | docker.io/lycheeverse/lychee:latest |
1 Critical, 4 High, 20 Medium, 60 Low, 1 Unknown |
| SQLFluff lint | SQLFLUFF_IMAGE | docker.io/sqlfluff/sqlfluff:latest |
3 Critical, 9 High, 34 Medium, 86 Low, 1 Unknown |
| Test SSL | TESTSSL_IMAGE | docker.io/drwetter/testssl.sh:latest |
|
| Terraform | TF_CHECKOV_IMAGE | docker.io/bridgecrew/checkov |
9 High, 31 Medium, 87 Low, 1 Unknown |
| Terraform | TF_DOCS_IMAGE | quay.io/terraform-docs/terraform-docs:edge |
6 High, 22 Medium, 6 Low |
| Terraform | TF_IMAGE | docker.io/hashicorp/terraform:latest |
1 High, 4 Medium, 3 Low |
| Terraform | TF_INFRACOST_IMAGE | docker.io/infracost/infracost |
72 Critical, 807 High, 727 Medium, 20 Low, 2 Unknown |
| Terraform | TF_PUBLISH_IMAGE | docker.io/curlimages/curl:latest |
3 Medium, 3 Low |
| Terraform | TF_TFLINT_IMAGE | ghcr.io/terraform-linters/tflint-bundle:latest |
7 Critical, 58 High, 173 Medium, 5 Low, 2 Unknown |
| Terraform | TF_TFSEC_IMAGE | docker.io/aquasec/tfsec-ci |
15 High, 34 Medium, 8 Low |
| Terraform | TF_TRIVY_IMAGE | docker.io/aquasec/trivy |
2 High, 8 Medium, 5 Low |
| Zola | ZOLA_IMAGE | docker.io/jauderho/zola:latest |
|
| Zola | ZOLA_LYCHEE_IMAGE | docker.io/lycheeverse/lychee:latest |
1 Critical, 4 High, 20 Medium, 60 Low, 1 Unknown |