On this page
unpinned-image#
A container image is used without a tag, with the latest tag, or, for
the pedantic persona, with a tag but no digest.
| Severity | medium no tag or latestlow a tag without a digest |
|---|---|
| Confidence | high |
| Persona | regularpedantic for a tag without a digest |
What it finds#
agent { docker { image 'maven' } } // maven is reported
docker.image('node:latest').inside { } // node:latest is reported
It reads the image wherever a pipeline names one to pull:
- Declarative Docker agents:
agent { docker 'maven' }andagent { docker { image 'maven' } }, for the pipeline or one stage - Docker Pipeline:
docker.image('maven'), with.inside,.run,.withRunor.pull - the Kubernetes plugin:
containerTemplate(name: 'maven', image: 'maven')
An image with a digest, maven:3.9.9@sha256:..., is pinned and not
reported. A registry's port, as in localhost:5000/maven, is not taken for
a tag.
Why it matters#
latestis whatever was pushed last. An image without a tag islatest. Each build may get a different image: a new major version that breaks the build, or, if the publisher's account or registry is compromised, an image that runs an attacker's code with the build's credentials and workspace.- Builds stop being reproducible. Rerunning last week's build does not run last week's tools.
- A tag can move too. Its publisher can push another image under
maven:3.9.9. Only a digest names exactly one image, which is why the pedantic persona also reports tags without one.
How to fix it#
Use a version tag, and add the image's digest:
agent {
docker {
image 'maven:3.9.9-eclipse-temurin-21@sha256:<digest>'
}
}
docker buildx imagetools inspect maven:3.9.9-eclipse-temurin-21 or
docker inspect --format '{{index .RepoDigests 0}}' <image> prints the
digest. Keep the tag next to it, so that people can read which version it
is. Dependabot and Renovate can open pull requests that update both.
What it does not report#
- Images that Groovy computes:
docker.image(params.IMAGE),image "${env.REGISTRY}/maven". - Images a pipeline builds:
docker.build('app')anddockerfileagents. TheFROMlines of the Dockerfile are where those are pinned; a Dockerfile linter such as Hadolint reports them (DL3006, DL3007). - Images in shell steps (
sh 'docker run maven') and in pod YAML.
When to ignore it#
When the job is meant to follow the newest image, such as a nightly build that tests compatibility with it.
// jenkinsfilelint: ignore[unpinned-image] a nightly job that tests the newest image
agent { docker { image 'node:latest' } }
How precise it is#
On 17,367 public Jenkinsfiles and shared library steps from GitHub, it
reports 1,177 findings in 625 files with the regular persona. In a random
sample of 50, 49 used an image with no tag or with latest. The other one,
image '$BUILDER_IMAGE', a variable in single quotes, is no longer
reported. A few of the 49 name images that the pipeline may build itself
earlier, such as ubuntu_ci:latest, which Docker then does not pull.
References#
- Docker: Pull an image by digest
- Hadolint: DL3006 and DL3007, the same problem in Dockerfiles
- zizmor: unpinned-images, the same problem in GitHub Actions