Skip to main content

SKY-D314 · CI/CD pipelines

GitLab CI mutable container image

High

HIGH for a Docker-in-Docker image (a name such as docker:27-dind). Every other image without a tag, or tagged latest, is MEDIUM.

Every GitLab CI job runs inside a container image, and can start extra service containers next to it. SKY-D314 reports images that can change under the same name: no tag, the latest tag, or a Docker-in-Docker service that is not pinned by its digest (@sha256:…).

Languages
GitLab CI
Quality gate
counted toward the gate limits (full and diff scans)
Finding type
review
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

Whoever can push to that image name decides what your job runs next time. A Docker-in-Docker service runs privileged and receives everything the job builds and pushes, so a replaced docker:dind image can plant code in your release image or read the registry credentials.

What Skylos flags

.gitlab-ci.yml · YAMLReported on line 15
stages: [test, build] test:  stage: test  image: python:3.12-slim  script:    - pip install -r requirements.txt    - pytest build-image:  stage: build  image: docker:27.3  timeout: 30 minutes  services:    - docker:27.3-dind  script:    - docker build -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA" .    - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA"

What Skylos leaves alone

.gitlab-ci.yml · YAML
stages: [test] test:  stage: test  image: python:3.12-slim  services:    - postgres:16.4  script:    - pip install -r requirements.txt    - pytest

Why Skylos leaves it alone

Both images carry a fixed version tag, which this rule accepts. It reports only images with no tag, the latest tag, or Docker-in-Docker. A tag can still be pushed again with new content, so a release job is safer pinned by digest anyway.

How Skylos decides

  1. Runs with --danger (and -a). Reads every file named exactly .gitlab-ci.yml in the scanned folder, skipping .git, node_modules, .venv, venv, build, dist and cache folders. A subfolder scan of a Git repository also reads the repository's top-level .gitlab-ci.yml. Files pulled in with include: are not read.
  2. Skips a file that PyYAML's safe loader cannot read, without a warning. That includes every file that uses GitLab's !reference tag.
  3. Collects the top-level image and services, those under default:, and those of every job. A job is any top-level key that is not a GitLab keyword and holds a mapping, hidden .template jobs included; extends: is not followed.
  4. An image name counts as mutable when it has no @sha256: digest and either has no tag, has the tag latest, or is a Docker-in-Docker image (the last path part contains both docker and dind), whatever its tag. Any other tag, such as python:3.12-slim, passes.
  5. Reports one finding per image and place (top level, default or job), HIGH for Docker-in-Docker and MEDIUM otherwise, on the first line of the file that contains the image name.

How to fix it

Pin the image by digest. Keep the tag in front of the digest so readers still see the version; GitLab pulls by the digest. Look the digest up with docker buildx imagetools inspect docker:27.3-dind and update it on purpose, for example through Renovate.

.gitlab-ci.yml · YAML · the fix, against the flagged file
stages: [test, build] test:  stage: test  image: python:3.12-slim  script:    - pip install -r requirements.txt    - pytest build-image:  stage: build  image: docker:27.3  timeout: 30 minutes  services:Removed:     - docker:27.3-dindAdded:     - docker:27.3-dind@sha256:9c8f3c6a0e1b5f4d2a7e8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e  script:    - docker build -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA" .    - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA"

When it can be wrong

  • An image named only by a variable, such as $CI_REGISTRY_IMAGE/builder or $BUILD_IMAGE, has no visible tag and is reported, even when the variable always holds a digest.
  • Hidden .template jobs are checked as jobs, so an image in a template is reported there, not in the jobs that extend it.
  • When the same image name appears in several places, every finding points at its first line in the file.
  • The docker push line of the flagged example is also a SKY-D340 finding, about publishing from CI. That one is separate.

Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.

How to silence it

  • Put # skylos: ignore[SKY-D314] and a reason on the reported line, or on the line directly above it. Skylos looks for that exact text, so write one rule per marker, with the ID in upper case.

    YAML
    services:  # skylos: ignore[SKY-D314] internal mirror, rebuilt and scanned nightly  - docker:27.3-dind
  • A baseline hides the findings that exist today. Each entry records the rule, the absolute file path and the line, so it stops matching when the line moves or the checkout is at another path.

  • [tool.skylos] ignore = ["SKY-D314"] turns the rule off for the whole project.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.