Skip to content

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.

You should either :

  • use a fixed version tag : using the maven:3.9.1 instead of maven:latest make sure you stay on a specific version of tools
    • prefer official image with the least tools (prefer minimal size, Alpine distribution or even distro-less if you can find one suited to your needs), the more the image has, heavier is the risk
  • build and maintain your own image with a chosen version for each tools
    • use no or a minimal distribution
    • upgrade tools and important components regularly with safe updates
    • root-less image are best 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)

Warning

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
AnsibleANSIBLE_IMAGEregistry.hub.docker.com/cytopia/ansible:latest-tools 5 Medium, 1 Low, 2 Unknown
AnsibleANSIBLE_LINT_IMAGEregistry.hub.docker.com/haxorof/ansible-lint:latest
Amazon Web ServicesAWS_CLI_IMAGEregistry.hub.docker.com/amazon/aws-cli:latest
AzureAZURE_CLI_IMAGEmcr.microsoft.com/azure-cli:latest 2 Medium, 1 Low
BashBASH_BATS_IMAGEregistry.hub.docker.com/bats/bats:latest 2 High, 2 Medium, 2 Low, 2 Unknown
BashBASH_SHELLCHECK_IMAGEregistry.hub.docker.com/koalaman/shellcheck-alpine:stable 22 Medium, 4 Low, 2 Unknown
BrunoBRU_IMAGEregistry.hub.docker.com/library/node:lts-alpine
GitLab ButlerBUTLER_IMAGEregistry.gitlab.com/to-be-continuous/tools/gitlab-butler:latest 2 High, 2 Medium, 2 Unknown
Cloud FoundryCF_CLI_IMAGEregistry.hub.docker.com/governmentpaas/cf-cli 6 Critical, 22 High, 52 Medium, 2 Low, 3 Unknown
Cloud Native BuildpacksCNB_BUILDER_IMAGEdocker.io/paketobuildpacks/builder-jammy-base:latest 104 Critical, 104 High, 1088 Medium, 134 Low
Cloud Native BuildpacksCNB_SKOPEO_IMAGEquay.io/skopeo/stable:latest
Cloud Native BuildpacksCNB_TRIVY_IMAGEdocker.io/aquasec/trivy:latest 2 High, 4 Medium, 1 Low, 3 Unknown
CypressCYPRESS_IMAGEregistry.hub.docker.com/cypress/included:13.13.3 12 Critical, 91 High, 204 Medium, 282 Low, 59 Unknown
dbtDBT_IMAGEghcr.io/dbt-labs/dbt-core:latest 5 Critical, 277 High, 988 Medium, 572 Low, 2 Unknown
Docker ComposeDCMP_IMAGEregistry.hub.docker.com/library/docker:latest 1 Critical, 1 High, 11 Medium
DefectDojoDEFECTDOJO_BASE_IMAGEregistry.hub.docker.com/library/node:alpine3.11 1 Critical, 25 High, 3 Medium, 1 Low
Dependency TrackDEPTRACK_SBOM_SCANNER_IMAGEregistry.gitlab.com/to-be-continuous/tools/dt-sbom-scanner:latest
DockerDOCKER_BUILDAH_IMAGEquay.io/buildah/stable:latest
DockerDOCKER_DIND_IMAGEregistry.hub.docker.com/library/docker:dind 1 Critical, 1 High, 11 Medium
DockerDOCKER_HADOLINT_IMAGEregistry.hub.docker.com/hadolint/hadolint:latest-alpine 8 High, 12 Medium
DockerDOCKER_IMAGEregistry.hub.docker.com/library/docker:latest 1 Critical, 1 High, 11 Medium
DockerDOCKER_KANIKO_IMAGEgcr.io/kaniko-project/executor:debug 7 Critical, 8 High, 25 Medium, 5 Low
DockerDOCKER_SBOM_IMAGEregistry.hub.docker.com/anchore/syft:debug 3 Medium, 1 Unknown
DockerDOCKER_SKOPEO_IMAGEquay.io/skopeo/stable:latest
DockerDOCKER_TRIVY_IMAGEregistry.hub.docker.com/aquasec/trivy:latest 2 High, 4 Medium, 1 Low, 3 Unknown
Google CloudGCP_CLI_IMAGEgcr.io/google.com/cloudsdktool/cloud-sdk:latest 3 Critical, 72 High, 440 Medium, 502 Low, 2 Unknown
GitleaksGITLEAKS_IMAGEregistry.hub.docker.com/zricethezav/gitleaks:latest 1 Critical, 4 Medium, 1 Low, 3 Unknown
GitLab PackageGLPKG_IMAGEregistry.hub.docker.com/curlimages/curl:latest 2 Unknown
GoGO_CI_LINT_IMAGEregistry.hub.docker.com/golangci/golangci-lint:latest-alpine 2 High, 2 Medium, 1 Unknown
GoGO_IMAGEregistry.hub.docker.com/library/golang:bookworm 2 Critical, 66 High, 417 Medium, 385 Low, 2 Unknown
GoGO_SBOM_IMAGEregistry.hub.docker.com/cyclonedx/cyclonedx-gomod:latest 2 High, 65 Medium, 2 Low, 2 Unknown
GoGO_SEMGREP_IMAGEregistry.hub.docker.com/semgrep/semgrep:latest 5 Medium, 3 Low, 4 Unknown
GradleGRADLE_IMAGEregistry.hub.docker.com/library/gradle:latest 25 Medium, 35 Low
HelmfileHELMFILE_CLI_IMAGEghcr.io/helmfile/helmfile:latest 4 Critical, 6 High, 38 Medium, 2 Low, 4 Unknown
HelmHELM_CLI_IMAGEregistry.hub.docker.com/alpine/helm:latest 1 Medium
HelmHELM_KUBE_SCORE_IMAGEregistry.hub.docker.com/zegl/kube-score 8 Critical, 53 High, 67 Medium, 4 Low, 2 Unknown
HelmHELM_YAMLLINT_IMAGEregistry.hub.docker.com/cytopia/yamllint 6 High, 12 Medium, 2 Unknown
HurlHURL_IMAGEghcr.io/orange-opensource/hurl:latest 2 Low, 2 Unknown
k6K6_IMAGEregistry.hub.docker.com/grafana/k6:latest 2 High, 2 Medium, 2 Unknown
KubernetesK8S_KUBECTL_IMAGEregistry.hub.docker.com/bitnami/kubectl:latest 1 Critical, 9 High, 32 Medium, 96 Low
KubernetesK8S_KUBE_SCORE_IMAGEregistry.hub.docker.com/zegl/kube-score:latest 8 Critical, 53 High, 67 Medium, 4 Low, 2 Unknown
LighthouseLHCI_IMAGEregistry.hub.docker.com/cypress/browsers:latest 4 Critical, 17 High, 127 Medium, 242 Low, 59 Unknown
GNU MakeMAKE_IMAGEregistry.hub.docker.com/alpinelinux/build-base 3 High, 10 Medium, 6 Low, 4 Unknown
MavenMAVEN_IMAGEregistry.hub.docker.com/library/maven:latest 25 Medium, 35 Low
MkDocsMKD_IMAGEdocker.io/squidfunk/mkdocs-material:latest 1 High, 1 Medium, 1 Low, 3 Unknown
MkDocsMKD_LYCHEE_IMAGEdocker.io/lycheeverse/lychee:latest 1 Critical, 1 High, 20 Medium, 57 Low
MobSFMOBSF_CLIENT_IMAGEregistry.hub.docker.com/badouralix/curl-jq
AngularNG_CLI_IMAGEregistry.hub.docker.com/trion/ng-cli-karma:latest 2 Critical, 72 High, 431 Medium, 485 Low, 2 Unknown
Node.jsNODE_IMAGEregistry.hub.docker.com/library/node:lts-alpine
Node.jsNODE_SEMGREP_IMAGEregistry.hub.docker.com/semgrep/semgrep:latest 5 Medium, 3 Low, 4 Unknown
OpenShiftOS_CLI_IMAGEquay.io/openshift/origin-cli:latest 3 Critical, 2 High, 5 Medium
PHPPHP_IMAGEregistry.hub.docker.com/library/php:latest 1 Critical, 66 High, 409 Medium, 359 Low, 2 Unknown
PlaywrightPLAYWRIGHT_IMAGEmcr.microsoft.com/playwright:latest 351 Medium, 114 Low
PostmanPOSTMAN_IMAGEregistry.hub.docker.com/postman/newman:latest 4 High, 32 Medium, 5 Low, 2 Unknown
pre-commitPRE_COMMIT_IMAGEregistry.hub.docker.com/library/python:3-alpine
PuppeteerPUPPETEER_IMAGEghcr.io/puppeteer/puppeteer:latest 6 Critical, 99 High, 513 Medium, 656 Low, 4 Unknown
PythonPYTHON_IMAGEregistry.hub.docker.com/library/python:3-slim 1 Critical, 1 High, 21 Medium, 58 Low
RenovateRENOVATE_IMAGEregistry.hub.docker.com/renovate/renovate:latest 5 High, 783 Medium, 71 Low
Robot FrameworkROBOT_BASE_IMAGEregistry.hub.docker.com/ppodgorsek/robot-framework:latest 1 Low
Source-to-ImageS2I_DIND_IMAGEregistry.hub.docker.com/library/docker:dind 1 Critical, 1 High, 11 Medium
Source-to-ImageS2I_SKOPEO_IMAGEquay.io/skopeo/stable:latest
S3 (Simple Storage Service)S3_CMD_IMAGEregistry.hub.docker.com/d3fk/s3cmd:latest 2 Unknown
Scala/SBTSBT_IMAGEregistry.hub.docker.com/sbtscala/scala-sbt:17.0.2_1.6.2_3.1.3 52 Critical, 213 High, 273 Medium, 570 Low, 2 Unknown
Scala/SBTSBT_SBOM_IMAGEregistry.hub.docker.com/anchore/syft:debug 3 Medium, 1 Unknown
semantic-releaseSEMREL_IMAGEregistry.hub.docker.com/library/node:lts-slim 1 Critical, 1 High, 18 Medium, 57 Low
SonarQubeSONAR_SCANNER_IMAGEregistry.hub.docker.com/sonarsource/sonar-scanner-cli:latest
SpectralSPECTRAL_IMAGEregistry.hub.docker.com/stoplight/spectral:latest 4 High, 39 Medium, 7 Low, 4 Unknown
SphinxSPHINX_IMAGEghcr.io/sphinx-doc/sphinx:latest 2 Critical, 6 High, 32 Medium, 154 Low
SphinxSPHINX_LYCHEE_IMAGEregistry.hub.docker.com/lycheeverse/lychee:latest 1 Critical, 1 High, 20 Medium, 57 Low
SQLFluff lintSQLFLUFF_IMAGEregistry.hub.docker.com/sqlfluff/sqlfluff:latest 2 Critical, 5 High, 30 Medium, 78 Low
Test SSLTESTSSL_IMAGEregistry.hub.docker.com/drwetter/testssl.sh:latest
TerraformTF_CHECKOV_IMAGEregistry.hub.docker.com/bridgecrew/checkov 1 Critical, 6 High, 34 Medium, 100 Low
TerraformTF_DOCS_IMAGEquay.io/terraform-docs/terraform-docs:edge 3 High, 6 Medium, 2 Unknown
TerraformTF_IMAGEregistry.hub.docker.com/hashicorp/terraform:latest 1 Critical, 3 High, 6 Medium, 1 Low, 3 Unknown
TerraformTF_INFRACOST_IMAGEregistry.hub.docker.com/infracost/infracost 73 Critical, 731 High, 535 Medium, 20 Low, 2 Unknown
TerraformTF_PUBLISH_IMAGEregistry.hub.docker.com/curlimages/curl:latest 2 Unknown
TerraformTF_TFLINT_IMAGEghcr.io/terraform-linters/tflint-bundle:latest 7 Critical, 35 High, 118 Medium, 4 Low, 2 Unknown
TerraformTF_TFSEC_IMAGEregistry.hub.docker.com/aquasec/tfsec-ci 2 High, 8 Medium, 3 Low, 3 Unknown
TerraformTF_TRIVY_IMAGEregistry.hub.docker.com/aquasec/trivy 2 High, 4 Medium, 1 Low, 3 Unknown