Ensure service account tokens are only mounted where necessary

Security & Compliance
No items found.

In Kubernetes, service account tokens are used for authentication and authorization purposes. If an attacker gains access to a pod that has access to a service account token, they can use that token to access other resources in the cluster. Hence, it is important to ensure that service account tokens are only mounted where necessary. Service account tokens should be mounted only in pods that require them. Pods that do not require service account tokens should have them disabled to avoid the risk of exposure to unauthorized parties. Also, ensure that sensitive information is not stored in the service account token itself, but rather in a separate secret or configuration file that is mounted into the pod. This will help to limit the amount of information that an attacker can access if they do gain access to the service account token.‍


Here are the steps to ensure that service account tokens are only mounted where necessary:

  1. Review the deployment configurations of all pods in the cluster to identify which pods are mounting service account tokens.
  2. For each pod, determine if the service account token is necessary for the application to function properly. If not, remove the mount of the service account token from the pod configuration.
  3. For pods where the service account token is necessary, ensure that the pod is using a minimal service account with only the necessary permissions to perform its intended function.
  4. Monitor the cluster to ensure that new pods are not introduced with unnecessary service account token mounts.
  5. Review the Kubernetes documentation on Service Accounts and RBAC to ensure you have a solid understanding of best practices around their use.

Enforced Resources
Note: Remediation steps provided by Lightlytics are meant to be suggestions and guidelines only. It is crucial to thoroughly verify and test any remediation steps before applying them to production environments. Each organization's infrastructure and security needs may differ, and blindly applying suggested remediation steps without proper testing could potentially cause unforeseen issues or vulnerabilities. Therefore, it is strongly recommended that you validate and customize any remediation steps to meet your organization's specific requirements and ensure that they align with your security policies and best practices.