Rules / GL065
GL065 Container image from a non-allowlisted registry
Severity: warn
OWASP: CICD-SEC-4 – Poisoned Pipeline Execution
CWE: CWE-829 – Inclusion of Functionality from Untrusted Control Sphere
Risk
A pipeline can pull an image: or services: entry from any registry. An image from an untrusted or unexpected registry runs with full access to the job's secrets and build context, so a compromised or malicious image is a direct path to pipeline execution. Teams that mandate a curated internal registry (or a small set of trusted public ones) have no way to enforce that from .gitlab-ci.yml alone.
How glsec checks
This rule is opt-in and config-driven: it does nothing until you set allowed_registries: in .glsec.yml. Once set, glsec flags any image: / services: reference whose registry is not on the list.
# .glsec.yml
allowed_registries:
- registry.example.com # bare host — any image from this registry is allowed
- ghcr.io/myorg # host + namespace — only this namespace is allowed
- No-op when unset — without
allowed_registries, nothing is flagged (so the default behaviour does not complain about everydocker.ioimage). - Registry host is the part before the first
/when it contains a.or:port(or islocalhost). Bare images likenode:20and Docker Hub namespaces likemyorg/appresolve todocker.ioimplicitly. - Docker Hub aliases — the canonical Docker Hub hostnames
index.docker.ioandregistry-1.docker.ioare folded todocker.io, so allowlistingdocker.ioalso permitsindex.docker.io/library/node:20. - Bare-host entries (
registry.example.com) match by host; namespace entries (ghcr.io/myorg) match as a host/namespace prefix, soghcr.io/myorg/appis allowed butghcr.io/other/appis not. - Variable hosts are exempt —
image: $MY_IMAGEorimage: $REGISTRY/appcannot be resolved statically and are not flagged (a resolvable host with a variable path, e.g.docker.io/$IMAGE, is still checked).
Trigger example
# .glsec.yml has allowed_registries: [registry.example.com]
build:
image: docker.io/library/node:20 # flagged — docker.io is not on the allowlist
script:
- ./build.sh
Safe alternative
build:
image: registry.example.com/node:20
script:
- ./build.sh
Notes
- Mirrors the config-driven model used by GL016 (
trusted-hosts). - To allow Docker Hub explicitly, add
docker.ioto the list.
Documentation for glsec 1.23.0. Source of this page · Rule implementation