CNCF TAG-Security Kyverno Security Self Assessment

Completed:tbd
Security reviewer(s):John Kinsella, Wesley Steehouwer (@dutchshark)
Project security lead:Jim Bugwadia
Source code:https://github.com/kyverno/kyverno
Web site:https://kyverno.io/

Table of contents

Metadata

Softwarehttps://github.com/kyverno/kyverno
Security ProviderYes
LanguagesGo
SBOMTo download and verify the SBOM for a specific version, visit https://kyverno.io/docs/security/#fetching-the-sbom-for-kyverno
Compatibilityhttps://kyverno.io/docs/installation/#compatibility-matrix
Docurl
Kyverno Security Documentationhttps://main.kyverno.io/docs/security/

Overview

Kyverno helps secure and automates Kubernetes configurations using policies defined as Kubernetes custom resources. It operates as an Kubernetes admission controller and a command-line for off-cluster use.

Background

Kubernetes has a declarative configuration management system that allows users to specify the desired state of resources which Kubernetes controllers continuously reconcile with the current system state. For flexibility, and to address a wide set of use cases, Kubernetes provides several configuration options for each resource.

While this is powerful, it also creates a few challenges:

  1. Only a small subset of configuration options are commonly used.
  2. Kubernetes configurations are not secure by default. Security and best practices need to be configured for workloads.
  3. A resource’s configurations is shared across organizational roles (dev-sec-ops) and chances of misconfigurations, or lack of proper configuration, increase as there is no clear ownership. Whether developers, operators, or security engineers are responsible for more advanced configuration settings may not be obvious.

Goal

The goal of the Kyverno project is to simplify Kubernetes configuration security and automate processes that otherwise require manual handoffs and coordination across Kubernetes cluster operators and developers.

Non-goals

Kyverno is not a general purpose policy engine i.e. it is not designed for use outside of Kubernetes.

Self-assessment use

This self-assessment is created by the Kyverno team to perform an internal analysis of the project’s security. It is not intended to provide a security audit of Kyverno, or function as an independent assessment or attestation of Kyverno’s security health.

This document serves to provide Kyverno users with an initial understanding of Kyverno’s security, where to find existing security documentation, Kyverno plans for security, and general overview of Kyverno security practices, both for development of Kyverno as well as security of Kyverno.

This document provides the CNCF TAG-Security with an initial understanding of Kyverno to assist in a joint-review, necessary for projects under incubation. Taken together, this document and the joint-review serve as a cornerstone for if and when Kyverno seeks graduation and is preparing for a security audit.

Logical Architecture

The following diagram shows the logical architecture for Kyverno. Each major component is described below:

Kyverno Logical Architecture

Admission Controller

The Admission Controller component registers as a validating and mutating admission webhook and receives AdmissionReview requests from the API server to validate and mutate configuration changes, based on policies. Users can configure which namespaces and resources the webhooks will receive via command line options or the ConfigMap.

The Admission Controller also creates and updates UpdateRequest, ClusterEphemeralReport and EphemeralReport resources to trigger updates via other Kyverno controllers.

Cert Renewer

On startup, Kyverno’s Cert Renewer component generates a self-signed certificate (or uses a user-provided certificate) and stores it in Kyverno managed secret. The component also renews the generated certificate 15 days before it becomes invalid.

Webhook Controller

On startup, Kyverno’s Webhook Controller component auto-creates the webhook configurations required to register Kyverno as an admission webhook with the certificate fetched from Kyverno managed secret. The component also periodically monitors if Kyverno is receiving webhook events and recreates the certificate and webhook configurations if needed.

Background Controller

The Background Controller watches UpdateRequest resources and creates, updates, and deletes Kubernetes resources based on Kyverno generate rules , or mutate existing Kubernetes resources based on mutate exsiting rules . The Background Controller also watches for changes in policy definitions to update generated resources.

Report Controllers

The Report Controller merges ClusterEphemeralReport and EphemeralReport generated by Admission Controller to Kyverno Policy Report . The component performs periodic background scans on existing configurations and creates or updates policy reports based on changes and background scans. The Report Controller watches ClusterEphemeralReport and EphemeralReport resources and creates, updates, and delete Kyverno Policy Report resources. The Policy Controller also watches for changes in policies definitions to update policy reports.

Physical Architecture

Kyverno can be installed using a Helm chart or YAML files (see installation doc ).

The Kyverno application consists of a:

  1. Deployments
  • Admission controller (required): The main component of Kyverno which handles webhook callbacks from the API server for verification, mutation, Policy Exceptions, and the processing engine.
  • Background controller (optional): The component responsible for processing of generate and mutate-existing rules.
  • Reports controller (optional): The component responsible for handling of Policy Reports.
  • Cleanup controller (optional): The component responsible for processing of Cleanup Policies.
  1. Services
  • Services needed to receive webhook requests.
  • Services needed for monitoring of metrics.
  1. ServiceAccounts
  • One ServiceAccount per controller to segregate and confine the permissions needed for each controller to operate on the resources for which it is responsible.
  1. ConfigMaps
  • ConfigMap for holding the main Kyverno configuration.
  • ConfigMap for holding the metrics configuration.
  1. Secrets
  • Secrets for webhook registration and authentication with the API server.
  1. Roles and Bindings
  • Roles and ClusterRoles, Bindings and ClusterRoleBindings authorizing the various ServiceAccounts to act on the resources in their scope.
  1. Webhooks
  • ValidatingWebhookConfigurations for receiving both policy and resource validation requests.
  • MutatingWebhookConfigurations for receiving both policy and resource mutating requests.
  1. CustomResourceDefinitions
  • CRDs which define the custom resources corresponding to policies, reports, and their intermediary resources.

When Kyverno runs, it will check for a named Secret with a certificate to use for webhook registration. If the secret does not exist, Kyverno will generate a self-signed certificate and store it in the secret. Kyverno will then generate or update the mutating and validating webhook configurations.

The diagram below shows the Kyverno physical architecture:

Kyverno Physical Architecture

Security functions and features

Kyverno operates as an webhook admission controller.

Threat Modeling

A threat model for admission controllers is published and maintained by the Kubernetes TAG Security:

The Kyverno security document references this threat model and discusses mitigations and best practices:

https://main.kyverno.io/docs/security/#threat-model

Project compliance

Kyverno does not currently document meeting particular compliance standards.

Secure development practices

The Kyverno project follows established CNCF and OSS best practices for code development and delivery:

Development Pipeline

All code is maintained in Git and changes must be reviewed by maintainers and must pass all unit and e2e tests. Code changes are submitted via Pull Requests (PRs) and must be signed. Commits to the main branch are not allowed.

Artifacts

The Kyverno container images are hosted in GitHub Container Registry (GHCR). Container images are signed using Sigstore Cosign ( https://main.kyverno.io/docs/security/#verifying-kyverno-container-images .)

The Kyverno Helm chart is hosted in ArtifactHub. There is a pending issue to to sign the Helm Chart using Sigstore Cosign ( https://github.com/kyverno/kyverno/issues/2758) .

The Kyverno installation YAMLs are hosted in the GitHub repository.

A Software Bill of Materials (SBOM) is produced and made available for each release ( https://main.kyverno.io/docs/security/#fetching-the-sbom-for-kyverno) .

Communication Channels

Security processes

Kyverno’s processes for security issue resolution, responsible disclosure, vulnerability response, and incident response are documented at:

https://main.kyverno.io/docs/security/

A security email alias kyverno-security is available for security disclosures and related communications.

Appendix

Known Issues Over Time

All Kyverno security related issues (both fixes and enhancements) are labeled with “security” and can be queried using:

https://github.com/kyverno/kyverno/labels/security

CII Best Practices

The Kyverno project has adopted the OSSF/Scorecard and is tracking progress in issue #2617 .

OPA/Gatekeeper is another CNCF project that acts as an admission controller and supports policy management. It uses Rego as its policy language.

A detailed comparison is available at: https://neonmirrors.net/post/2021-02/kubernetes-policy-comparison-opa-gatekeeper-vs-kyverno/ .