Profile Applicability:

  • Level 1

Description:

Ensure that the --service-account-lookup argument is set to true in the Kubernetes API server configuration. This argument enables the API server to look up service account names during authentication and authorization checks. When set to true, Kubernetes will verify the service account name as part of the authentication process to ensure that the service account is valid and properly authorized.

Rationale:

Enabling the --service-account-lookup argument ensures that the API server properly verifies service account names during authentication and authorization. This helps prevent issues where service account tokens could be accepted for non-existent or unauthorized service accounts, thereby enhancing the security of the cluster by ensuring that only valid and authorized service accounts can authenticate with the API server.

Impact:

Pros:

  • Enhances security by ensuring that service account names are validated, preventing unauthorized access via invalid service account tokens.

  • Ensures that service account-related operations are properly authorized and validated.

Cons:

  • Disabling or misconfiguring this setting could allow invalid or unauthorized service accounts to authenticate, leading to potential security risks or misconfigured access control.

Default Value:

By default, the --service-account-lookup argument may not be set, and service account name validation may be disabled. It must be manually configured to true to enable service account lookup.

Pre-Requisites:

  • Access to the Kubernetes API server configuration.

  • Sufficient privileges (root or administrator access) to modify the API server flags.

  • A Kubernetes environment where service account lookup is required for enhanced security.

Test Plan:

Using AWS Console:

  1. Sign in to the AWS Management Console.

  2. Open the Amazon Elastic Kubernetes Service (EKS) console.

  3. Navigate to the "Clusters" section and locate your cluster.

  4. Review the settings for the --service-account-lookup argument in the API server configuration.

  5. Ensure that the --service-account-lookup argument is set to true.

Using AWS CLI:

Retrieve the configuration for the Kubernetes API server:

kubectl get deployment -n kube-system kube-apiserver -o yaml

Check for the presence of the --service-account-lookup argument in the API server arguments section:

- --service-account-lookup=true
  1. Ensure that the --service-account-lookup argument is set to true. If it is not, update the configuration to enable service account lookup.

Implementation Plan:

Using AWS Console:

  1. Sign in to the AWS Management Console.

  2. Open the EKS service and navigate to your cluster.

  3. Review the cluster's configuration for the --service-account-lookup argument.

  4. If the argument is missing or set incorrectly, update the API server configuration to set --service-account-lookup=true.

  5. Save and apply the changes to the Kubernetes API server configuration.

Using AWS CLI:

Modify the API server deployment by adding or updating the --service-account-lookup=true argument:

kubectl edit deployment -n kube-system kube-apiserver
  1. In the deployment YAML, locate the command section under the spec for the kube-apiserver container.

Add or update the following line to enable service account lookup:

- --service-account-lookup=true
  1. Save and exit the editor to apply the changes.

Backout Plan:

Using AWS Console:

  1. Sign in to the AWS Console.

  2. Open the EKS service and navigate to your cluster.

  3. Locate the API server configuration.

  4. If necessary, revert the change by setting the --service-account-lookup argument to false or restoring the default configuration.

  5. Save and apply the changes to the Kubernetes API server configuration.

Using AWS CLI:

To revert the change, edit the API server deployment to set the --service-account-lookup argument to false:

kubectl edit deployment -n kube-system kube-apiserver
  1. Update the deployment YAML to include --service-account-lookup=false if needed.

  2. Save and exit the editor to apply the changes.

References: