SKY-D314 · CI/CD pipelines
GitLab CI mutable container image
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
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
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
stages: [test] test: stage: test image: python:3.12-slim services: - postgres:16.4 script: - pip install -r requirements.txt - pytestWhy 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
- Runs with
--danger(and-a). Reads every file named exactly.gitlab-ci.ymlin the scanned folder, skipping.git,node_modules,.venv,venv,build,distand cache folders. A subfolder scan of a Git repository also reads the repository's top-level.gitlab-ci.yml. Files pulled in withinclude:are not read. - Skips a file that PyYAML's safe loader cannot read, without a warning. That includes every file that uses GitLab's
!referencetag. - Collects the top-level
imageandservices, those underdefault:, and those of every job. A job is any top-level key that is not a GitLab keyword and holds a mapping, hidden.templatejobs included;extends:is not followed. - An image name counts as mutable when it has no
@sha256:digest and either has no tag, has the taglatest, or is a Docker-in-Docker image (the last path part contains bothdockeranddind), whatever its tag. Any other tag, such aspython:3.12-slim, passes. - 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.
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/builderor$BUILD_IMAGE, has no visible tag and is reported, even when the variable always holds a digest. - Hidden
.templatejobs 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 pushline 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-dindA 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.