C-0236: make the image signature verification policy configurable (no-tlog and keyless signing)
Overview
Control C-0236 ("Verify image signature") is backed by the regolibrary rule verify-image-signature, which calls the cosign.verify(image, key) Rego builtin once for each entry in data.postureControlInputs.trustedCosignPublicKeys. The builtin is implemented by verify() in core/pkg/opaprocessor/cosign_verify.go.
verify() hardcodes a single policy: a PEM public key, a Rekor entry required, and the claim check that was added in #3930. The only thing an operator can configure is the list of public keys.
Problem
Two common signing setups can't be expressed today, and C-0236 reports them as failures:
Key-signed images without a transparency-log entry.
cosign sign --key ... --tlog-upload=falseis the usual flow for private registries and air-gapped clusters.verify()setsRekorPubKeysbut noRekorClientand noIgnoreTlog, so cosign's online lookup path errors out. Run againstupstream/master(11038ce7) with an in-memory registry and a correctly key-signed image whose signature has no bundle:key-signed, no Rekor bundle: ok=false err=verifying signature: no matching signatures: rekor client not provided for online verificationThe rule then emits
signature not verified for image: .... Rejecting this by default is correct:cosign verify --keydoes the same. But the CLI lets the operator opt out with--insecure-ignore-tlogor--rekor-url, and C-0236 gives no equivalent.Keyless (Fulcio/OIDC) signatures. The builtin accepts only a public key, so images signed with
cosign signkeyless (identity + OIDC issuer, as most CI pipelines now do) can never pass C-0236, whatever the operator configures.
The file already lists the settings that were apparently meant to exist. VerifyCommand in the same file declares RekorURL, CertIdentity, CertOidcIssuer, EnforceSCT, RegistryOptions and others, but the type has no constructor and no references anywhere in the repository.
Solution
Expose the verification policy through control inputs, the project's existing mechanism for per-deployment settings, and translate them into cosign.CheckOpts in verify(). For example:
cosignRequireTransparencyLog(defaulttrue, today's behaviour). Whenfalse, setCheckOpts.IgnoreTlog = true, equivalent tocosign verify --insecure-ignore-tlog.cosignRekorURL(optional): buildCheckOpts.RekorClientso signatures without a bundle can be checked online against a public or private Rekor.- Later: keyless trust entries (
certIdentity/certOidcIssuer, with regexp variants) checked against the Fulcio roots, so C-0236 can cover keyless signing.
Defaults would keep today's results unchanged. This needs a matching change in kubescape/regolibrary to pass the new inputs to the builtin, whether through extra arguments or a new builtin, so I'd like maintainer input on the shape before starting.
The unused VerifyCommand struct could be removed as part of this or wired up as the options holder.
Alternatives
- Always set
IgnoreTlog = true. This is simpler, but it would also stop checking the Rekor bundle on public images, which weakens the control for everyone. - Document that C-0236 supports only key-signed images that have a Rekor entry. That's honest, but it leaves private-registry and keyless users with a control that always fails.
Additional context
core/pkg/opaprocessor/cosign_verify.go(verify(),VerifyCommand)core/pkg/opaprocessor/utils.go(cosign.verifybuiltin registration)- kubescape/regolibrary
rules/verify-image-signature/raw.rego,controls/C-0236-verifyimagesignature.json - Related: #3930 (claim verification, merged). #2992 is about signing kubescape's own output, not verifying images.
Source: kubescape/kubescape