Safeguard
Developer Tools•

How do you pin images and tools in a GitLab pipeline?

Pin job images by SHA digest, install exact tool versions with checksums, and use locked dependency installs. A short checklist drawn from GitLab guidance.

Safeguard Security Team
3 min read

Pin job images by SHA digest, install tools at exact versions and check their checksums, and install dependencies from a lockfile. Each rule removes a place where a changed upstream can alter your build without a review. GitLab's pipeline security guidance recommends all three.

Images

GitLab's pipeline security page says to always use SHA digests for Docker images, to ensure client-side integrity verification. A tag such as latest can point at a different image tomorrow. A digest cannot. It also suggests protected container repositories and protected tags to control who can change images, and to avoid variables in image references, because a variable can be changed to point to a malicious image.

build:
  image: node:22@sha256:0000000000000000000000000000000000000000000000000000000000000000

The digest above is a placeholder. Use the real value from your registry.

Tools installed in scripts

When a job downloads a tool, specify and verify the exact version, and check the checksum. A line that fetches whatever is current trusts the download site with your build. Version managers such as nvm pin runtimes.

Dependencies

Use locked, exact installs: npm ci, a frozen lockfile for Yarn, or hash-verified installs for pip, as GitLab lists. See npm ci versus npm install for why.

Includes and components

Pin include references to a commit SHA, protected tag or specific version, and avoid versionless includes. For remote files, GitLab suggests copying them into your repository and including the local copy. See project versus remote includes and components and templates.

ItemWeakBetter
Job imageimage: node:latestTag with digest
Tool downloadCurrent release URLExact version plus checksum
Dependenciesnpm installnpm ci with lockfile
IncludeBranch or no versionSHA or protected tag

Steps to roll it out

  1. List every image, include and download line in your pipeline files.
  2. Replace moving references with fixed ones, one pipeline at a time.
  3. Add a scheduled job that checks for newer versions and opens a change for review. Pinning without updating leaves known vulnerabilities in place.
  4. Scan the pinned image, since a fixed digest can still hold flaws. See container image scanning in CI.
  5. Require review on pipeline file changes. See CODEOWNERS for pipeline files.

Common mistakes

Teams pin an image tag but not its digest, or pin the job image while the build downloads tools without checksums. Another error is pinning and then never updating, so known flaws live on. Make the update path as easy as the pin: a scheduled job that proposes new digests, a review, and a scan before the change merges.

Try it yourself

Click through it at your own pace, or open it full screen. Look at how a scan reports findings against a specific image, which is why a pinned digest is worth scanning.

Safeguard's dependency and SBOM scanning shows what a pinned build contains, and you can try a free scan at https://gold.safeguard.sh/scan.

Quick check

Does pinning make me safe?

No. It makes the build repeatable. You still need scans and a plan to update.

Which is better, a tag or a digest?

A digest, because a tag can be moved. Keep the tag beside it for readability.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.