Описание
Kyverno ignores subjectRegExp and IssuerRegExp
Summary
Kyverno ignores subjectRegExp and IssuerRegExp while verifying artifact's sign with keyless mode. It allows the attacker to deploy kubernetes resources with the artifacts that were signed by unexpected certificate.
Details
Kyverno checks only subject and issuer fields when verifying an artifact's signature: https://github.com/Mohdcode/kyverno/blob/373f942ea9fa8b63140d0eb0e101b9a5f71033f3/pkg/cosign/cosign.go#L537. While there are subjectRegExp and issuerRegExp fields that can also be used for the defining expected subject and issue values. If the last ones are used then their values are not taken in count and there is no actually restriction for the certificate that was used for the image sign.
PoC
For the successful exploitation attacker needs:
- Private key of any certificate in the certificate chain that trusted by cosign. It can be certificate that signed by company's self-signed Root CA if they are using their own PKI.
- Access to container registry to push artifacts images
- Availability to deploy malicious artifacts to the kubernetes cluster
- Generate certificate that will be used for the image signing with the oidcissuer url. That can be done with the Fulcio or manually by using openssl
- Build and push container image
- Import key and sign the image with the generated certificate
- Add ClusterPolicy for the Kyverno with the wrong subject and issuer regexp. Adding (Fulcio) Root CA as secret and using it in policy is optional only if cosign cannot trust it:
- Deploy previously signed image
- The deployment with pods will be create successfully due to not checking subjectRegExp and issuerRegExp fields validation
Impact
Deploying unauthorized kubernetes resources that can lead to full compromise of kubernetes cluster
P.S.
Problem was discovered by me when testing image sign verifying with keyless signing: https://kubernetes.slack.com/archives/CLGR9BJU9/p1740136401365279?thread_ts=1740136401.365279&cid=CLGR9BJU9. Then it was verified and fixed by Mohcode. But i think it should be registered as security problem such as it allows to bypass part of the verification mechanism and Kyverno users should be aware of it.
Ссылки
- https://github.com/kyverno/kyverno/security/advisories/GHSA-46mp-8w32-6g94
- https://nvd.nist.gov/vuln/detail/CVE-2025-29778
- https://github.com/kyverno/policies/issues/1246
- https://github.com/kyverno/kyverno/pull/12237
- https://github.com/kyverno/kyverno/commit/8777672fb17bdf252bd2e7d8de3441e240404a60
- https://github.com/Mohdcode/kyverno/blob/373f942ea9fa8b63140d0eb0e101b9a5f71033f3/pkg/cosign/cosign.go#L537
Пакеты
github.com/kyverno/kyverno
>= 1.13.0, < 1.13.5
1.14.0-alpha.1
Связанные уязвимости
Kyverno is a policy engine designed for cloud native platform engineering teams. Prior to version 1.14.0-alpha.1, Kyverno ignores subjectRegExp and IssuerRegExp while verifying artifact's sign with keyless mode. It allows the attacker to deploy kubernetes resources with the artifacts that were signed by unexpected certificate. Deploying these unauthorized kubernetes resources can lead to full compromise of kubernetes cluster. Version 1.14.0-alpha.1 contains a patch for the issue.