3 ms·
Here's my Kubernetes security horror story. You probably know about resolv.conf, but you might not know about "search domains". A feature that should've never
by crabbone 3y ago
Here's my Kubernetes security horror story.
You probably know about resolv.conf, but you might not know about "search domains". A feature that should've never existed, but was added because "why not?". If you don't know what it does, in first approximation, it creates a domain alias. This is sometimes used to save some typing when using DNS for service discovery in larger clusters in a very hierarchical way (when names start to look like a.b.c.d.e.f.g...com, it's tempting to alias them to something shorter).
So, long story short. Ubuntu LTS had a bug (actually a whole bunch of them) in the same script that was responsible for generation of this file (it's a bad idea to have this file to begin with... but hey, who cares, right?). So, one aspect of the bug was that a variable name "DOMAINS" was used instead of its value. And that became a search address in resolv.conf.
Now, this search works by appending the search path to the domain name, if DNS server tells you it cannot find it. I had no idea DOMAINS was possible to register as a valid domain name. I mean, it should've been a TLD to be discoverable globally, right? -- Well, it's still a mystery to me, but, for some reason domains of the form a.b.c.DOMAINS are resolved to some AWS EC2 instance...
And, the punch line: if you screw up CoreDNS configuration somehow, or something else goes wrong with service discovery inside your Kubernetes cluster on unpatched Ubuntu -- there's a good chance your traffic will go to that EC2 instance. Who's on the other side -- I don't know. I didn't send anything important that way and discovered it because something like Spark operator didn't work... but it could've been much worse.
Oh, btw, I believe resolv.conf is used by different CNIs. Maybe Calico and Flanel. I cannot remember atm. why it was used... or maybe it's some kubelet setting.
Anyways. Larger point is... large Kubernetes clusters are virtually impossible to systematically audit. Too many things can do too many things. Too much trickery goes on in all sorts of system components that deal with networking. It's also impossible to track who does what and who owns what because there's no user identity.
---
I believe that, again, industry adopted an absolute horror show of a program / environment not because it was a great tool, but because "organically" developers started to add "features", creating something that's hard to resist, because, superficially, it creates a lot of value with minimal effort -- but it also lays a trap that is not immediately obvious. And those who find themselves trapped, instead of running away, star adding more "features" to fight the trap. But, in this foolhardy attempt, they only make the trap stronger.
- uberduper 3y agoI'm not familiar with w/e issue of Ubuntu caused `search domains` to end up in your resolv.conf. I'm skeptical it wasn't just a misconfiguration. At any rate, you had a problem with your host configuration. The kubelet will merge the hosts resolver config with the cluster config to generate a resolv.conf file for the pods it runs, resulting in the issue you described. This can cause other annoying dns issues. It has nothing to do with CoreDNS. The only way I've found to disable this kubelet behavior is to start the kubelet with `--resolv-conf=/dev/null`
- crabbone 3y agoThis is one of the series of bugs I'm referring to: https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/1981103 https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/1981... . I'm too lazy to search for all of them. But if you pull by this thread, you should be able to find more. Don't be skeptical. It just sounds like you think you know better, when you actually have no clue.
- uberduper 3y agoSkeptical-o-meter just went over 9000.
- cratermoon 3y ago> Ubuntu LTS had a bug > resolved to some AWS EC2 instance How is this a Kubernetes problem, and not an Ubuntu/AWS issue?
- crabbone 3y agoYou might want to read the whole post you replied to before asking questions already answered in that post.
- cratermoon 3y agoI'm replying to your comment, which brings up a lot of tangential issues about Ubuntu and AWS, none of which are specific to Kubernetes. As other replies have pointed out, "you had a problem" and the bug ticket you linked doesn't even mention k8s. Skept-o-meter over 9000 indeed.