Skip to content

NimTechnology

Trình bày các công nghệ CLOUD một cách dễ hiểu.

  • Kubernetes & Container
    • Docker
    • Kubernetes
      • Ingress
      • Pod
    • Helm Chart
    • OAuth2 Proxy
    • Isito-EnvoyFilter
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Vault
    • Longhorn – Storage
    • VictoriaMetrics
    • MetalLB
    • Kong Gateway
  • CI/CD
    • ArgoCD
    • ArgoWorkflows
    • Argo Events
    • Spinnaker
    • Jenkins
    • Harbor
    • TeamCity
    • Git
      • Bitbucket
  • Coding
    • DevSecOps
    • Terraform
      • GCP – Google Cloud
      • AWS – Amazon Web Service
      • Azure Cloud
    • Golang
    • Laravel
    • Python
    • Jquery & JavaScript
    • Selenium
  • Log, Monitor & Tracing
    • DataDog
    • Prometheus
    • Grafana
    • ELK
      • Kibana
      • Logstash
  • BareMetal
    • NextCloud
  • Toggle search form

[DevSecOps] Anonymous Authentication in Kubernetes

Posted on July 13, 2023July 13, 2023 By nim No Comments on [DevSecOps] Anonymous Authentication in Kubernetes

Nguồn: https://krolcloud.com/blog/anonymous-authentication-in-kubernetes/?fbclid=IwAR1U9U6yzxJoF6tKwUQgkHAyqpB-mL8RMJ_ot8SLaXzseHKPEfZEMfDKHi4

Contents

Toggle
  • Kubernetes Anonymous Users 
  • By Default – Anonymous Users 
    • Let’s get some statistics about Kubernetes versions exposed on the internet 
      • Using Shodan.io 
      • Using Censys.io 
    • Kubelet Authentication Authorization 
        • Turning off Anonymous Requests 
  • Adding permissions to the user anonymous – Don’t do it ! 
        • Before Permission 
        • Adding Permission 
        • After Permission 
  • Kubernetes RBAC Tools 
    • Finding anonymous-xdemo clusterrolebinding in the tools report 

Kubernetes Anonymous Users 

Let’s uncover the details of Kubernetes 💥anonymous users and how 💥RBAC tooling works with anonymous access.

By default, every request to the Kubernetes API that isn’t otherwise associated with a specific user is treated as coming from an anonymous user. This can be startling at first glance, with some wondering if this is a security vulnerability. But fear not, it’s all by design, and it’s a fundamental part of Kubernetes’ role-based access control (RBAC) system.

By Default – Anonymous Users 

These are the commands that can be used with anonymous access by default:

curl -k $SERVER/version
curl -k $SERVER/healthz

🔱 The testing environment was a kubernetes 1.24 using kind, details Here →

curl -k $SERVER/version
{
  "major": "1",
  "minor": "24",
  "gitVersion": "v1.24.15",
  "gitCommit": "2c67202dc0bb96a7a837cbfb8d72e1f34dfc2808",
  "gitTreeState": "clean",
  "buildDate": "2023-06-15T01:09:03Z",
  "goVersion": "go1.19.10",
  "compiler": "gc",
  "platform": "linux/amd64"
}

curl -k $SERVER/healthz
ok%

Let’s get some statistics about Kubernetes versions exposed on the internet 

Using search engines, we can track all the kubernetes version:

Using Shodan.io 

Using Censys.io 

Image by @raesene, follow the link for more about anonymous →

Kubelet Authentication Authorization 

Vulnerable Kubernetes clusters with authentication set to –anonymous-auth=true, allowing anyone anonymous access to the Kubernetes API.

Turning off Anonymous Requests 

There might be situations where you’d want to disable anonymous requests entirely for more stringent security. That’s entirely doable by setting the –anonymous-auth=false flag on the API server. However, it’s worth noting that this could impact components and features that rely on anonymous access, so ensure you understand the implications before making this change.

The setting anonymous-auth= is inside the default config file /var/lib/kubelet/config.yaml

Read more in the Kubelet Kubernetes Documentation → and Kubelet Authentication Authorization →

Adding permissions to the user anonymous – Don’t do it ! 

RBAC in Kubernetes provides the framework for authorizing API requests based on the user’s role.

By default, the anonymous user doesn’t have any permissions. However, admins can grant permissions to anonymous users by binding roles to the 💥system:anonymous💥 group or the 💥system:unauthenticated💥 group, which includes all anonymous users.

Remember, roles define the permissions, which include actions like read, write, and execute, and these are bound to a user through role bindings.

For instance, you might want to allow anonymous users to list the pods in a particular namespace to keep an eye on your cluster’s health. To do that, you would create a Role with the appropriate permissions and then bind it to the system:unauthenticated group.

Before Permission 
k get pods --as=system:anonymous

Error from server (Forbidden): pods is forbidden: User "system:anonymous" cannot list resource "pods" in API group "" in the namespace "default"

Adding Permission 
kubectl create clusterrolebinding anonymous-xdemo --clusterrole=view --user=system:anonymous
After Permission 
kubectl get pods -A --as=system:anonymous
NAMESPACE            NAME                                              READY   STATUS    RESTARTS      AGE
kube-system          coredns-57575c5f89-5j9n2                          1/1     Running   1 (21h ago)   35h
kube-system          coredns-57575c5f89-h7zbn                          1/1     Running   1 (21h ago)   35h
kube-system          etcd-rbac-demo-control-plane                      1/1     Running   1 (21h ago)   35h
kube-system          kindnet-rxqsm                                     1/1     Running   1 (21h ago)   35h
kube-system          kube-apiserver-rbac-demo-control-plane            1/1     Running   1 (21h ago)   35h
kube-system          kube-controller-manager-rbac-demo-control-plane   1/1     Running   1 (21h ago)   35h
kube-system          kube-proxy-dsbhz                                  1/1     Running   1 (21h ago)   35h
kube-system          kube-scheduler-rbac-demo-control-plane            1/1     Running   1 (21h ago)   35h
local-path-storage   local-path-provisioner-c49b7b56f-t48qf            1/1     Running   2 (21h ago)   35h

Kubernetes RBAC Tools 

Exploring the reports searching for the risk of the anonymous user in the Kubernetes cluster.

It was added the anonymous permissions and the tools were executed to find the risk of this configuration.

🔱 The testing environment was a kubernetes 1.24 using kind, details Here →

Finding anonymous-xdemo clusterrolebinding in the tools report 

Krane
🚫 Not found alert for anonymous user with permissions, issue open here💥.
Krane output report here ✍🏿


KubiScan
✅ Found an alert for anonymous user with permissions, issue open here – done💥.
KubiScan output report here ✍🏿 kubiscan
Kubescape
🚫 Not found alert for anonymous user with permissions, issue open here – WIP💥.
Kubescape output report here ✍🏿 kubescape
Rbac-Police
🚫 Not found alert for anonymous user with permissions, issue open here 💥.
Rbac-Police output report here ✍🏿 rbac-police
AWS-GuardDuty
✅ Found an alert for anonymous user with permissions.
AWS-GuardDuty report detail coming 💥 aws-guardduty
Kubernetes

Post navigation

Previous Post: [Grafana] How to publish Grafana Dashboard for the community.
Next Post: [DevSevOps] How to Install OpenVAS

More Related Articles

[Kubernetes] How to delete POD is Terminating and very stubborn Kubernetes
[Terraform / EKS] Build EKS and Karpenter by Terraform. AWS - Amazon Web Service
[Vault] Eliminate Kubernetes Secrets With Secrets Store CSI Driver (SSCSID) Kubernetes
[AWS] Pull images from ECR AWS - Amazon Web Service
[KOS] Use KOS to install kubernetes so easily! Kubernetes
[Tetragon] Security Observability and Runtime Enforcement Kubernetes

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Tham Gia Group DevOps nhé!
Để Nim có nhiều động lực ra nhiều bài viết.
Để nhận được những thông báo mới nhất.

Recent Posts

  • [Azure] The subscription is not registered to use namespace ‘Microsoft.ContainerService’ May 8, 2025
  • [Azure] Insufficient regional vcpu quota left May 8, 2025
  • [WordPress] How to add a Dynamic watermark on WordPress. May 6, 2025
  • [vnet/Azure] VNet provisioning via Terraform. April 28, 2025
  • [tracetcp] How to perform a tracert command using a specific port. April 3, 2025

Archives

  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Categories

  • BareMetal
    • NextCloud
  • CI/CD
    • Argo Events
    • ArgoCD
    • ArgoWorkflows
    • Git
      • Bitbucket
    • Harbor
    • Jenkins
    • Spinnaker
    • TeamCity
  • Coding
    • DevSecOps
    • Golang
    • Jquery & JavaScript
    • Laravel
    • NextJS 14 & ReactJS & Type Script
    • Python
    • Selenium
    • Terraform
      • AWS – Amazon Web Service
      • Azure Cloud
      • GCP – Google Cloud
  • Kubernetes & Container
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Docker
    • Helm Chart
    • Isito-EnvoyFilter
    • Kong Gateway
    • Kubernetes
      • Ingress
      • Pod
    • Longhorn – Storage
    • MetalLB
    • OAuth2 Proxy
    • Vault
    • VictoriaMetrics
  • Log, Monitor & Tracing
    • DataDog
    • ELK
      • Kibana
      • Logstash
    • Fluent
    • Grafana
    • Prometheus
  • Uncategorized
  • Admin

Copyright © 2025 NimTechnology.