Future of CRDs: Structural Schemas

Future of CRDs: Structural Schemas

  • June 28, 2019
Table of Contents

Future of CRDs: Structural Schemas

CustomResourceDefinitions were introduced roughly two years ago as the primary way to extend the Kubernetes API with custom resources. From the beginning they stored arbitrary JSON data, with the exception that kind, apiVersion and metadata had to follow the Kubernetes API conventions. In Kubernetes 1.8 CRDs gained the ability to define an optional OpenAPI v3 based validation schema.

By the nature of OpenAPI specifications though—only describing what must be there, not what shouldn’t, and by being potentially incomplete specifications—the Kubernetes API server never knew the complete structure of CustomResource instances. As a consequence, kube-apiserver—until today—stores all JSON data received in an API request (if it validates against the OpenAPI spec). This especially includes anything that is not specified in the OpenAPI schema.

To understand this, we assume a CRD for maintenance jobs by the operations team, running each night as a service user: The privileged field is not specified by the operations team. Their controller does not know it, and their validating admission webhook does not know about it either.

Nevertheless, kube-apiserver persists this suspicious, but unknown field without ever validating it. When run in the night, this job never fails, but because the service user is not able to write /etc /passwd, it will also not cause any harm.

The maintenance team needs support for privileged jobs. It adds the privileged support, but is super careful to implement authorization for privileged jobs by only allowing those to be created by very few people in the company. That malicious job though has long been persisted to etcd.

The next night arrives and the malicious job is executed.

Source: kubernetes.io

Share :
comments powered by Disqus

Related Posts

How big companies are using Kubernetes

How big companies are using Kubernetes

Kubernetes’ increased adoption is showcased by a number of influential companies which have integrated the technology into their services. Let us take a look at how some of the biggest companies of our time are successfully using Kubernetes. The Docker adoption is still growing exponentially, more and more companies have started using it in Production.

Read More
KubeCon EU 2019: Top 10 Takeaways

KubeCon EU 2019: Top 10 Takeaways

The Datawire team and I have returned home from an awesome time last week where we attended KubeCon and CloudNativeCon in Barcelona. Together, we were part of six talks at KubeCon, staffed a packed booth with amazing T-shirts (if I do say so myself!), spoke to dozens of community members, and attended some fantastic talks. As there was so much goodness on offer at KubeCon EU, I’ve tried to summarise some of my key observations in this blog post.

Read More