Supply chain security
Enforcing Image Policy
1.Where a check can run
A policy covers only the requests and fields it sees. Webhooks and VAP syntax : Admission Control.
- CI checks manifests but only advises : anyone can
kubectl applyaround it. - Admission runs once per API write, before any pull.
- The runtime checks every real pull, never cached images.
2.The gap between admit and pull
- Admission verifies
app:1.0at digest A. The tag moves to B. A later pull gets B, never verified. - Fix : pin digests in Git, or let the verifier append one. All three keep the tag :
podinfo:6.9. 2@sha256:cab90e...
3.Every field that holds an image
A Pod-only rule admits the Deployment, then denies its Pods as ReplicaSet FailedCreate, as in Pod Security. kubectl debug --copy-to makes a new Pod, so pods rules see it.
| Field | Reached by | Trap |
|---|---|---|
| containers, initContainers | Pod CREATE | Examples often check containers only |
| ephemeralContainers | kubectl debug : UPDATE | pods, * miss it : list pods/ |
| volumes[].image.reference | Pod CREATE | Skipped by every admission verifier by default |
| spec.template.spec | Deployment, StatefulSet, DaemonSet, Job | Unchecked unless listed |
| spec.jobTemplate.spec.template.spec | CronJob | One more path for your CEL |
4.What built-in CEL can do
variables: # Pod form - name: images expression: >- object.spec.?containers.orValue([]).map(c, c.image) + object.spec.?initContainers.orValue([]).map(c, c.image) + object.spec.?ephemeralContainers.orValue([]).map(c, c.image) + object.spec.?volumes.orValue([]).filter(v, has(v.image)) .map(v, v.image.?reference.orValue('')) validations: - expression: variables.images.all(i, i.matches('@sha256:[a-f0-9]{64}$')) reason: Forbidden # 403, not 422
- Can :
startsWith,matches,all/exists. - Cannot : parse a reference, normalize
nginx, call a registry, resolve a tag. - End prefixes in
/: blocksregistry..example. com. evil. io - Forbid
:latest, even next to a digest.
5.Built-ins outside a webhook
- ImagePolicyWebhook (off by default) : Pods and debug containers only.
defaultAllow: falsefails closed. - Static image VAP (manifest-based, beta v1.37) : no
paramKind, so a hard-coded allow-list. Not deletable through the API. A broken file keeps the old one. - AlwaysPullImages : see Images, Registries and Pulls.
6.Commands
| Command | Shows |
|---|---|
kubectl debug -it <pod> --image=<ref>@sha256:<d> --target=<c> | A debug container : a separate request on the subresource |
kubectl describe rs <rs> | Late FailedCreate from a Pod-only rule |
kubectl get validatingadmissionpolicy <name> -o jsonpath='{. | CEL type errors |
kubectl get pod <p> -o jsonpath='{. | Whether digest pinning happened |
In short : Place each check, cover every image field, and keep CEL to string hygiene (no signatures).
1.Kyverno ImageValidatingPolicy
policies., GA since 1.17 (v1 storage planned for 1.20). The Namespaced kind acts in its own namespace.
| spec field | What it does |
|---|---|
| matchConstraints | Webhook rules, copied verbatim : list pods/ yourself |
| matchImageReferences | A scope on the raw string : unmatched images are skipped, not denied |
| images | Extra extractors (CEL). None built in for image volumes |
| attestors, attestations | cosign (key, keyless, trustedRoot) or notary. Claims by intoto.type or referrer.type |
| validations | CEL : verifyImageSignatures, verifyAttestationSignatures (count > 0) |
| validationConfigurations | mutateDigest, verifyDigest, required : all default true |
2.One Pod through Kyverno
- Autogen covers controllers only when
resourcesis exactly["pods"]. Addingpods/turns it off : use two policies.ephemeralcontainers
3.An IVPOL that pins a release workflow
matchImageReferences: [{glob: "ghcr.io/kyverno/*"}]
attestors:
- name: github
cosign:
keyless:
identities:
- issuer: https://token.actions.githubusercontent.com
subjectRegExp: '^https://github\.com/kyverno/kyverno/\.github/workflows/.+@refs/tags/v.+$'
source: {repository: ghcr.io/kyverno/signatures}
validations:
- expression: (images.containers + images.initContainers)
.all(i, verifyImageSignatures(i, [attestors.github]) > 0)
- Anchor
subjectRegExp. Kyverno keeps its signatures in another repo. - cosign v3 bundles are auto-detected. cosign attestors check only in-toto.
trustedRootsits next tokeyless, not inside it (docs nest it).- IVPOL never reads the Pod's
imagePullSecrets.spec.credentials(Kyverno namespace Secrets) replaces the helpers, no merge.
4.Kyverno version traps
- 1.19.0 made all three real : upgrades can deny.
- 1.19.1 fixes GHSA-5cjf-wwfg-pj4c : a one-image exception exempted the whole resource.
verifyImages(ClusterPolicy) : deprecated 1.19, removed in 1.20 (late 2026).- 1.19 is tested only on Kubernetes 1.33 to 1.35.
5.Sigstore policy-controller
- Opt-in namespaces only.
no-match-policydefaults to deny, so does a typo. - CIP : every matching one must pass, one authority in each is enough.
ctlog= Rekor. - v0.15.1 cannot verify cosign v3 bundle image signatures :
bundleis attestations only. - Chart 0.10.8 runs v0.13.1. No cache.
6.Commands
| Command | Shows |
|---|---|
kubectl get ivpol <name> -o jsonpath='{. | Which controllers got variants |
kubectl get ivpol <name> -o jsonpath='{. | Stored defaults (all three true) |
kubectl get policyreports -n <ns> | Audit results |
kubectl label namespace payments policy. | Opts a namespace in |
kubectl patch configmap/ | Warn on unmatched images |
In short : IVPOL verifies and pins matches. policy-controller cannot verify cosign v3 bundles.
1.Ratify behind Gatekeeper
- External data : a Gatekeeper
Provider, called from Rego withexternal_data. Responses cached 3m. - Ratify v1.4.6 is the stable line (
config.).ratify. deislabs. io/ v1beta1 - v2.0.0-beta.2 (
Executor) says "do not use in production" and renamed its API between betas. - The Gatekeeper chart fails open (
Ignore, 3s). The sample constraint covers only Pods indefault.
2.Checks on the node
- CRI-O :
policy.jsonper Pod namespace (/) withetc/ crio/ policies/<ns>. json sigstoreSigned. - containerd 2.x :
bindirverifiers (exit 0 allows), only on transfer-service pulls, the CRI default since 2.1. - Legacy
registry.mirrors/configs/authsordiscard_silently fall back to local pulls with no verifiers (kind's default did). Check :unpacked_ layers = true journalctl -u containerd | grep -i 'Falling back to local image pull' ctr image pull --localskips verifiers too : test withcrictl pull.
| CRI-O | containerd | |
|---|---|---|
| Keyless identity | Exact email SAN only : no GitHub workflow URIs | Whatever your binary does |
| cosign v3 bundles | No (container-libs issue 388) | Your binary |
| Cached images | Re-checked at create when a policy path is set | Never checked |
| Pod shows | SignatureValidationFailed | ErrImagePull, then ImagePullBackOff |
| Warn mode | None : test on a canary pool | None |
3.Failure and caching
Fail: a registry or Rekor outage blocks admission.- Kyverno with
Ignorestill denied on registry errors (observed once).[Audit]still mutates. - Caches : Kyverno 60m, Gatekeeper 3m, policy-ctrl none.
- Private Sigstore : Kyverno
trustedRoot/tuf, policy-controllerTrustRoot, Ratify verifier parameters.
4.Digest mutation and GitOps drift
- Kyverno (autogen), policy-controller and Ratify rewrite templates to
tag@sha256: Argo CD and Flux see drift. - Pin digests in Git, so there is nothing to rewrite : the
digeststrategy of Argo CD Image Updater, or a FluxImagePolicywithdigestReflectionPolicy(Flux). - Or hide the diff :
ignoreDifferencesin Argo CD.
5.Check in CI too, as advice
kyverno apply ivpol.yaml --resource rendered.yamlruns only the validating path : tag-only images failverifyDigest. A policy file without.yamlis skipped with exit 0.policy-tester -policy cip.yaml -image REFchecks one image against one CIP.
6.Which engine does what
| VAP | Kyverno 1.19 | policy-ctrl 0.15.1 | Ratify + GK | CRI-O | containerd | |
|---|---|---|---|---|---|---|
| Signatures | no | cosign, notary | cosign .sig only | notation, cosign | sigstore | your binary |
| Tag to digest | no | mutateDigest | always | Assign | n/a | n/a |
| kubectl debug | if listed | if listed | digest only | sent by default | at pull | at pull |
| Image volumes | if CEL reads | extractor | no | no | yes | yes |
| Pod templates | your rules | autogen | yes | mutate only | n/a | n/a |
| Unmatched | your CEL | skipped | deny | by scopes | default | allowed |
| Trial mode | [Warn, Audit] | [Audit] or [Warn] | mode, no-match : warn | dryrun, then warn | none | none |
| On failure | Fail | Fail | Fail | Ignore | pull fails | pull fails |
In short : Pin digests, cover every field, trial in warn mode, and back admission with node checks.