-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(controllermanager): add checks for Kubernetes Controller Manager #3291
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More checks for Kubernetes!! Great job @sergargar 🚀
Please check my comments since there are broken links in the metadata and we need to control execution within loops not to loop over everything if it is not configured as expected.
.../services/controllermanager/controllermanager_bind_address/controllermanager_bind_address.py
Show resolved
Hide resolved
"ResourceType": "KubernetesControllerManager", | ||
"Description": "This check ensures that profiling is disabled in the Kubernetes Controller Manager, reducing the potential attack surface.", | ||
"Risk": "Enabling profiling can expose detailed system and program information, which could be exploited if accessed by unauthorized users.", | ||
"RelatedUrl": "https://github.com/kubernetes/community/blob/master/contributors/devel/profiling.md", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broken link, if you use Github links please set the permalink.
}, | ||
"Recommendation": { | ||
"Text": "Disable profiling in the Kubernetes Controller Manager for enhanced security.", | ||
"Url": "https://kubernetes.io/docs/admin/kube-controller-manager/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broken link
f"Controller Manager has profiling enabled in pod {pod.name}." | ||
) | ||
for container in pod.containers.values(): | ||
if "--profiling=false" in str(container.command): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you have to check if this is not set and just break the loop if that happens.
f"Controller Manager has the root CA file set in pod {pod.name}." | ||
) | ||
for container in pod.containers.values(): | ||
if "--root-ca-file=" in str(container.command): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you have to check if this is not set and just break the loop if that happens.
}, | ||
"Recommendation": { | ||
"Text": "Configure the Controller Manager with a root CA file to enhance security for pods communicating with the API server.", | ||
"Url": "https://kubernetes.io/docs/admin/kube-controller-manager/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broken link.
"ResourceType": "KubernetesControllerManager", | ||
"Description": "This check verifies that the Kubernetes Controller Manager is configured with the --root-ca-file argument set to a certificate bundle file, allowing pods to verify the API server's serving certificate.", | ||
"Risk": "Not setting the root CA file can expose pods to man-in-the-middle attacks due to unverified TLS connections to the API server.", | ||
"RelatedUrl": "https://github.com/kubernetes/kubernetes/issues/11000", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the only resource available?
"ResourceType": "KubernetesControllerManager", | ||
"Description": "This check ensures that the Kubernetes Controller Manager is configured with the RotateKubeletServerCertificate argument set to true, enabling automated rotation of kubelet server certificates.", | ||
"Risk": "Not enabling kubelet server certificate rotation could lead to downtime due to expired certificates.", | ||
"RelatedUrl": "https://kubernetes.io/docs/admin/kubelet-tls-bootstrapping/#approval-controller", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broken link.
"ResourceType": "KubernetesControllerManager", | ||
"Description": "This check verifies that the Kubernetes Controller Manager is configured to use individual service account credentials for each controller, enhancing the security and role separation within the Kubernetes system.", | ||
"Risk": "Not using individual service account credentials can lead to overly broad permissions and potential security risks.", | ||
"RelatedUrl": "https://kubernetes.io/docs/admin/service-accounts-admin/", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broken link.
"ResourceType": "KubernetesControllerManager", | ||
"Description": "This check ensures that the Kubernetes Controller Manager is configured with the --service-account-private-key-file argument set to the private key file for service accounts.", | ||
"Risk": "Not setting a private key file for service accounts can hinder the ability to securely rotate service account tokens.", | ||
"RelatedUrl": "https://kubernetes.io/docs/admin/kube-controller-manager/", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broken link.
kubelete_server_cert = True | ||
for command in container.command: | ||
if command.startswith("--feature-gates"): | ||
if "RotateKubeletServerCertificate=true" in ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ar you sure of this logic? Wouldn't it be the other way around?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the above comment and we'll merge. Thanks!
Description
Add all checks for Kubernetes Controller Manager:
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.