Skip to content
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

control-service: don't include needless service token #1679

Merged
merged 1 commit into from
Feb 28, 2023

Conversation

antoniivanov
Copy link
Collaborator

Kubernetes, service accounts are used by pods to authenticate with the Kubernetes API server and access resources in the cluster. Each pod is assigned a service account, and by default, the service account token is mounted in the pod's file system and used for authentication.

However, not all pods need to access the Kubernetes API server or cluster resources, and in some cases, including the service account token can pose a security risk. For example, if a pod is compromised or runs untrusted code (which data job generally do), an attacker could use the service account token to escalate privileges and access sensitive resources in the cluster.

To mitigate this risk, Kubernetes provides the
automountServiceAccountToken property, which can be used to disable the automatic mounting of the service account token in pods. By setting this property to false, the service account token is not included by default, and the pod does not have access to the token unless it is manually mounted in a volume.

It is a best practice to follow the principle of least privilege when designing and configuring Kubernetes workloads. By disabling the automatic mounting of the service account token, we can reduce the attack surface of our pods (and hence data jobs) and minimize the risk of compromise or data breaches.

Testing Done: existing integration tests cover that the main functionality will not be broken by setting automountServiceAccountToken to false.

Kubernetes, service accounts are used by pods to authenticate with the
Kubernetes API server and access resources in the cluster. Each pod is
assigned a service account, and by default, the service account token is
mounted in the pod's file system and used for authentication.

However, not all pods need to access the Kubernetes API server or
cluster resources, and in some cases, including the service account
token can pose a security risk. For example, if a pod is compromised or
runs untrusted code (which data job generally do), an attacker could use
the service account token to escalate privileges and access sensitive
resources in the cluster.

To mitigate this risk, Kubernetes provides the
`automountServiceAccountToken` property, which can be used to disable
the automatic mounting of the service account token in pods. By setting
this property to false, the service account token is not included by
default, and the pod does not have access to the token unless it is
manually mounted in a volume.

It is a best practice to follow the principle of least privilege when
designing and configuring Kubernetes workloads. By disabling the
automatic mounting of the service account token, we can reduce the
attack surface of our pods (and hence data jobs) and minimize the risk
of compromise or data breaches.

Testing Done: existing integration tests cover that the main
functionality will not be broken by setting automountServiceAccountToken
to false.

Signed-off-by: Antoni Ivanov <aivanov@vmware.com>
Copy link
Contributor

@ivakoleva ivakoleva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The yaml indentation is hard to look&ensure...Would you verify the flag is effectively set for pods as well (verifying the change also works, in addition to not breaking stuff) 😊

@antoniivanov antoniivanov merged commit 768ec74 into main Feb 28, 2023
@antoniivanov antoniivanov deleted the person/aivanov/control-service-k8s-token branch February 28, 2023 10:11
yonitoo pushed a commit that referenced this pull request Mar 1, 2023
Kubernetes, service accounts are used by pods to authenticate with the
Kubernetes API server and access resources in the cluster. Each pod is
assigned a service account, and by default, the service account token is
mounted in the pod's file system and used for authentication.

However, not all pods need to access the Kubernetes API server or
cluster resources, and in some cases, including the service account
token can pose a security risk. For example, if a pod is compromised or
runs untrusted code (which data job generally do), an attacker could use
the service account token to escalate privileges and access sensitive
resources in the cluster.

To mitigate this risk, Kubernetes provides the
`automountServiceAccountToken` property, which can be used to disable
the automatic mounting of the service account token in pods. By setting
this property to false, the service account token is not included by
default, and the pod does not have access to the token unless it is
manually mounted in a volume.

It is a best practice to follow the principle of least privilege when
designing and configuring Kubernetes workloads. By disabling the
automatic mounting of the service account token, we can reduce the
attack surface of our pods (and hence data jobs) and minimize the risk
of compromise or data breaches.

Testing Done: existing integration tests cover that the main
functionality will not be broken by setting automountServiceAccountToken
to false.

Signed-off-by: Antoni Ivanov <aivanov@vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants