by 0xbadcafebee · 3y ago · 0 comments
Basically, the geniuses at Google decided to make clusters insecure by default, because being an admin is, like, hard, man. So guess what? People deployed clusters that were insecure by default.
I don't think it has ever been easier to take over cloud computing environments just by exploiting a dinky web app.
Openshift also had much strict RBAC settings from very beginning(like even in Openshift 3.x days, when k8s had no RBAC by default and you had to opt-in).
The baseline policy will disable hostPath volumes which helps a bit, alongside quite a few other restrictions.
I'm not talking about hackers, but just some less experienced people who might read that advice on forums or chats and decided to just proceed without asking.
One can use kyverno to enforce those namespace, but it's so heavyweight solution, I actually deployed it and it was terrible decision, so now I have to plan to decommission it.
There's mechanism to actually enforce default baseline policy, so even if it's not set on a namespace, it'll be "baseline". However to configure that mechanism one need to configure admission controller. But good luck configuring it with kubeadm. It requires some cryptic YAMLs, YAML patches and whatnot. You can't just edit some configmap in the cluster and be done with it.
https://kubernetes.io/docs/tasks/configure-pod-container/enf... this is what I'm talking about.
It's more issue with kubeadm, I guess, which really makes things harder than they should be. I can't just run kubeadm join control-plane, I need to craft configuration, add this AdmissionConfiguration to it, remember to update it on all control nodes if I decide to change it later.
There is a lot to unpack here, but while I agree with the main point (kubernetes defauls suck) the main problem I’ve seen all across the industry is that people expect to be able to install stuff around and that to be magically secure, functional and performant.
It just doesn’t work like that. Systems administration is its own discipline and you can’t expect to follow some random tutorial off the internet and be ready for production.
Also, it doesn’t help that the kubernetes documentation is awful.
I remember my time working with kubernetes, it’s a patchwork of stuff… it does require time and a fairly high pain threshold to properly master it.
You choose "up-and-running" defaults if you want people to be able to immediately run your software. So this means no encryption, no auth (or "the first user is the admin" kind of auth), storing your state in a bundled SQLite DB, etc. This helps with growth, because random devs can download the container image, run it and check out your features in five minutes. And then run it in production.
With production defaults everything is locked down. Go issue some certificates and make sure your OS (or JRE) trusts them, because your nodes won't talk to each other without TLS. No one has any rights to anything by default, can't even log in until you go and edit authN/Z configuration. The container will kill itself if the env var for the database password is still "change_this!". It's a pain to deploy this, but a pleasure to run.
Ideally, all products should come with two sets of defaults. Your AIO quickstart image should be easy to run. Your production-grade image or the configs that come with the distribution should be locked down tighter than Fort Knox.
K8s is a piece of infrastructure that doesn't really benefit from an "up and running" approach, but it has this kind of defaults for some reason instead of having every default policy resolve to "not allowed".
Carefully manage complexity, and write a good manual.
OpenBSD is about 22M lines of code; kubernetes is 58M, so the code bases are of comparable complexity (OpenBSD uses many more programming languages than kubernetes does).
I'd argue that the base OpenBSD install provides far more utility than Kubernetes, but market share numbers disagree.
Sources:
https://openhub.net/p/kubernetes https://www.reddit.com/r/openbsd/comments/d9a8c9/how_many_li...
Edit: Using open hub for both says OpenBSD is 75M lines:
My mind immediately went to Eddie Izzard’s “do you have a flag” bit.
> It just doesn’t work like that. Systems administration is its own discipline and you can’t expect to follow some random tutorial off the internet and be ready for production.
Disagree. I can install an app to my Sandstorm instance and reasonably expect it to be secure, functional, and performant (inasmuch as the app is performant anyway). The tools we use make things difficult, but I don't think there's as much irreducible complexity here as you're implying. We can and should build better tools.
Kinda proves my point: some random amateur sysadmin thinking their experience with sandstorm is enough to put kubernetes in production.
But thanks for replying, anyway.
Nothing in the middle.
There is little documentation on how to put the various pieces together. That’s all on various random webpages outside of the main kubernetes.io website.
The setup tutorial only describes some basic kubeadm-based setup. There’s a lot to improve, if you ask me.
RBAC is enabled by default on just about every distribution I've seen (with the notable exception of microk8s)
Lack of default admission control to prevent someone with pod creation access breakout to the host is indeed pretty common
Unencrypted APIs hasn't really been a problem in years, the insecure API port and read-only Kubelet were a thing but they've been disabled for quite a few versions now.
I'd definitely agree that early k8s versions had very bad security, but things have been improving gradually over the versions :)
Both GKE and EKS currently have insecure defaults. There's a half dozen ways to take over the entire cluster with the default settings.
The unencrypted API port is only this year being deprecated on GKE, I don't know about EKS.
Since you can only grant permissions, not deny, most people end up granting too many permissions, defeating the purpose of least privilege.
Default permissions for users on GKE/EKS are way too wide open. You can do things you just shouldn't need to do as a regular dev.
You shouldn't be able to just deploy a helm chart to a random cluster and then all of a sudden there's an unauthenticated public service on the internet. But that's what every single distribution of K8s gives users by default. Regardless of whether you think that's fine or not, this is how companies get exposed on a regular basis, so it is a real-world persistent security problem that is perpetuated by the defaults.
The support lifecycle is pretty short, compared to general enterprise software, so unless orgs are happy running unsupported versions of k8s they're on 1.23 for EKS or 1.24 for GKE by this point.
I wouldn't have said that EKS, in particular, had very bad defaults, IME it's the best of the managed distributions for security. Any references for 1/2 dozen ways of taking over a cluster from defaults settings? I'd genuinely be interested as I collect information about Kubernetes security, so I'm always on the look-out for more references.
for unencrypted API are you thinking of the Insecure API port or read-only Kubelet? For the insecure API port I don't think that's been a thing for a really long time on managed distros. The only time I remember seeing it was on ACS (the predecessor to AKS) where it was exposed to the container network. read-only Kubelet was more of a thing as that was on worker nodes, but it was less risky.
K8s is a "do one thing and do it well" that does workload orchestration. Google's BeyondCorp system enforces a zero-trust policy. It's not left to each part of the infrastructure to independently implement.
Not following this. Isn't a k8s cluster behind a network firewall? Only exposing 443? To me RBAC would be useful in a specific case where you want k8 service accounts (no one uses these) to have different levels of security. That sounds awful.
Of course not, unless you configure it this way.
> RBAC would be useful in a specific case where you want k8 service accounts (no one uses these) to have different levels of security.
What? How comes no one uses service accounts? They're used extensively for many things.