Skip to content

Commit ca08498

Browse files
committed
Provide a consistent appearance to bullets
1 parent f76f8ee commit ca08498

File tree

2 files changed

+78
-79
lines changed

2 files changed

+78
-79
lines changed

content/en/docs/concepts/security/rbac-good-practices.md

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ weight: 60
99

1010
<!-- overview -->
1111

12-
Kubernetes {{< glossary_tooltip text="RBAC" term_id="rbac" >}} is a key security control
13-
to ensure that cluster users and workloads have only the access to resources required to
12+
Kubernetes {{< glossary_tooltip text="RBAC" term_id="rbac" >}} is a key security control
13+
to ensure that cluster users and workloads have only the access to resources required to
1414
execute their roles. It is important to ensure that, when designing permissions for cluster
15-
users, the cluster administrator understands the areas where privilege escalation could occur,
15+
users, the cluster administrator understands the areas where privilege escalation could occur,
1616
to reduce the risk of excessive access leading to security incidents.
1717

1818
The good practices laid out here should be read in conjunction with the general
@@ -24,46 +24,46 @@ The good practices laid out here should be read in conjunction with the general
2424

2525
### Least privilege
2626

27-
Ideally, minimal RBAC rights should be assigned to users and service accounts. Only permissions
28-
explicitly required for their operation should be used. While each cluster will be different,
27+
Ideally, minimal RBAC rights should be assigned to users and service accounts. Only permissions
28+
explicitly required for their operation should be used. While each cluster will be different,
2929
some general rules that can be applied are :
3030

31-
- Assign permissions at the namespace level where possible. Use RoleBindings as opposed to
32-
ClusterRoleBindings to give users rights only within a specific namespace.
33-
- Avoid providing wildcard permissions when possible, especially to all resources.
34-
As Kubernetes is an extensible system, providing wildcard access gives rights
35-
not just to all object types that currently exist in the cluster, but also to all object types
36-
which are created in the future.
37-
- Administrators should not use `cluster-admin` accounts except where specifically needed.
38-
Providing a low privileged account with
39-
[impersonation rights](/docs/reference/access-authn-authz/authentication/#user-impersonation)
40-
can avoid accidental modification of cluster resources.
41-
- Avoid adding users to the `system:masters` group. Any user who is a member of this group
42-
bypasses all RBAC rights checks and will always have unrestricted superuser access, which cannot be
43-
revoked by removing RoleBindings or ClusterRoleBindings. As an aside, if a cluster is
44-
using an authorization webhook, membership of this group also bypasses that webhook (requests
45-
from users who are members of that group are never sent to the webhook)
31+
- Assign permissions at the namespace level where possible. Use RoleBindings as opposed to
32+
ClusterRoleBindings to give users rights only within a specific namespace.
33+
- Avoid providing wildcard permissions when possible, especially to all resources.
34+
As Kubernetes is an extensible system, providing wildcard access gives rights
35+
not just to all object types that currently exist in the cluster, but also to all object types
36+
which are created in the future.
37+
- Administrators should not use `cluster-admin` accounts except where specifically needed.
38+
Providing a low privileged account with
39+
[impersonation rights](/docs/reference/access-authn-authz/authentication/#user-impersonation)
40+
can avoid accidental modification of cluster resources.
41+
- Avoid adding users to the `system:masters` group. Any user who is a member of this group
42+
bypasses all RBAC rights checks and will always have unrestricted superuser access, which cannot be
43+
revoked by removing RoleBindings or ClusterRoleBindings. As an aside, if a cluster is
44+
using an authorization webhook, membership of this group also bypasses that webhook (requests
45+
from users who are members of that group are never sent to the webhook)
4646

4747
### Minimize distribution of privileged tokens
4848

4949
Ideally, pods shouldn't be assigned service accounts that have been granted powerful permissions
50-
(for example, any of the rights listed under [privilege escalation risks](#privilege-escalation-risks)).
50+
(for example, any of the rights listed under [privilege escalation risks](#privilege-escalation-risks)).
5151
In cases where a workload requires powerful permissions, consider the following practices:
5252

53-
- Limit the number of nodes running powerful pods. Ensure that any DaemonSets you run
53+
- Limit the number of nodes running powerful pods. Ensure that any DaemonSets you run
5454
are necessary and are run with least privilege to limit the blast radius of container escapes.
55-
- Avoid running powerful pods alongside untrusted or publicly-exposed ones. Consider using
56-
[Taints and Toleration](/docs/concepts/scheduling-eviction/taint-and-toleration/),
57-
[NodeAffinity](/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity), or
58-
[PodAntiAffinity](/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity)
59-
to ensure pods don't run alongside untrusted or less-trusted Pods. Pay especial attention to
60-
situations where less-trustworthy Pods are not meeting the **Restricted** Pod Security Standard.
55+
- Avoid running powerful pods alongside untrusted or publicly-exposed ones. Consider using
56+
[Taints and Toleration](/docs/concepts/scheduling-eviction/taint-and-toleration/),
57+
[NodeAffinity](/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity), or
58+
[PodAntiAffinity](/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity)
59+
to ensure pods don't run alongside untrusted or less-trusted Pods. Pay especial attention to
60+
situations where less-trustworthy Pods are not meeting the **Restricted** Pod Security Standard.
6161

6262
### Hardening
6363

64-
Kubernetes defaults to providing access which may not be required in every cluster. Reviewing
64+
Kubernetes defaults to providing access which may not be required in every cluster. Reviewing
6565
the RBAC rights provided by default can provide opportunities for security hardening.
66-
In general, changes should not be made to rights provided to `system:` accounts some options
66+
In general, changes should not be made to rights provided to `system:` accounts some options
6767
to harden cluster rights exist:
6868

6969
- Review bindings for the `system:unauthenticated` group and remove them where possible, as this gives
@@ -76,7 +76,7 @@ to harden cluster rights exist:
7676

7777
### Periodic review
7878

79-
It is vital to periodically review the Kubernetes RBAC settings for redundant entries and
79+
It is vital to periodically review the Kubernetes RBAC settings for redundant entries and
8080
possible privilege escalations.
8181
If an attacker is able to create a user account with the same name as a deleted user,
8282
they can automatically inherit all the rights of the deleted user, especially the
@@ -87,7 +87,7 @@ rights assigned to that user.
8787
Within Kubernetes RBAC there are a number of privileges which, if granted, can allow a user or a service account
8888
to escalate their privileges in the cluster or affect systems outside the cluster.
8989

90-
This section is intended to provide visibility of the areas where cluster operators
90+
This section is intended to provide visibility of the areas where cluster operators
9191
should take care, to ensure that they do not inadvertently allow for more access to clusters than intended.
9292

9393
### Listing secrets
@@ -125,7 +125,7 @@ If someone - or some application - is allowed to create arbitrary PersistentVolu
125125
includes the creation of `hostPath` volumes, which then means that a Pod would get access
126126
to the underlying host filesystem(s) on the associated node. Granting that ability is a security risk.
127127

128-
There are many ways a container with unrestricted access to the host filesystem can escalate privileges, including
128+
There are many ways a container with unrestricted access to the host filesystem can escalate privileges, including
129129
reading data from other containers, and abusing the credentials of system services, such as Kubelet.
130130

131131
You should only allow access to create PersistentVolume objects for:
@@ -135,56 +135,56 @@ You should only allow access to create PersistentVolume objects for:
135135
that are configured for automatic provisioning.
136136
This is usually setup by the Kubernetes provider or by the operator when installing a CSI driver.
137137

138-
Where access to persistent storage is required trusted administrators should create
138+
Where access to persistent storage is required trusted administrators should create
139139
PersistentVolumes, and constrained users should use PersistentVolumeClaims to access that storage.
140140

141141
### Access to `proxy` subresource of Nodes
142142

143-
Users with access to the proxy sub-resource of node objects have rights to the Kubelet API,
144-
which allows for command execution on every pod on the node(s) to which they have rights.
145-
This access bypasses audit logging and admission control, so care should be taken before
143+
Users with access to the proxy sub-resource of node objects have rights to the Kubelet API,
144+
which allows for command execution on every pod on the node(s) to which they have rights.
145+
This access bypasses audit logging and admission control, so care should be taken before
146146
granting rights to this resource.
147147

148148
### Escalate verb
149149

150-
Generally, the RBAC system prevents users from creating clusterroles with more rights than the user possesses.
150+
Generally, the RBAC system prevents users from creating clusterroles with more rights than the user possesses.
151151
The exception to this is the `escalate` verb. As noted in the [RBAC documentation](/docs/reference/access-authn-authz/rbac/#restrictions-on-role-creation-or-update),
152152
users with this right can effectively escalate their privileges.
153153

154154
### Bind verb
155155

156-
Similar to the `escalate` verb, granting users this right allows for the bypass of Kubernetes
157-
in-built protections against privilege escalation, allowing users to create bindings to
156+
Similar to the `escalate` verb, granting users this right allows for the bypass of Kubernetes
157+
in-built protections against privilege escalation, allowing users to create bindings to
158158
roles with rights they do not already have.
159159

160160
### Impersonate verb
161161

162-
This verb allows users to impersonate and gain the rights of other users in the cluster.
163-
Care should be taken when granting it, to ensure that excessive permissions cannot be gained
162+
This verb allows users to impersonate and gain the rights of other users in the cluster.
163+
Care should be taken when granting it, to ensure that excessive permissions cannot be gained
164164
via one of the impersonated accounts.
165165

166166
### CSRs and certificate issuing
167167

168-
The CSR API allows for users with `create` rights to CSRs and `update` rights on `certificatesigningrequests/approval`
169-
where the signer is `kubernetes.io/kube-apiserver-client` to create new client certificates
170-
which allow users to authenticate to the cluster. Those client certificates can have arbitrary
168+
The CSR API allows for users with `create` rights to CSRs and `update` rights on `certificatesigningrequests/approval`
169+
where the signer is `kubernetes.io/kube-apiserver-client` to create new client certificates
170+
which allow users to authenticate to the cluster. Those client certificates can have arbitrary
171171
names including duplicates of Kubernetes system components. This will effectively allow for privilege escalation.
172172

173173
### Token request
174174

175-
Users with `create` rights on `serviceaccounts/token` can create TokenRequests to issue
176-
tokens for existing service accounts.
175+
Users with `create` rights on `serviceaccounts/token` can create TokenRequests to issue
176+
tokens for existing service accounts.
177177

178178
### Control admission webhooks
179179

180-
Users with control over `validatingwebhookconfigurations` or `mutatingwebhookconfigurations`
181-
can control webhooks that can read any object admitted to the cluster, and in the case of
180+
Users with control over `validatingwebhookconfigurations` or `mutatingwebhookconfigurations`
181+
can control webhooks that can read any object admitted to the cluster, and in the case of
182182
mutating webhooks, also mutate admitted objects.
183183

184-
185184
## Kubernetes RBAC - denial of service risks {#denial-of-service-risks}
186185

187186
### Object creation denial-of-service {#object-creation-dos}
187+
188188
Users who have rights to create objects in a cluster may be able to create sufficient large
189189
objects to create a denial of service condition either based on the size or number of objects, as discussed in
190190
[etcd used by Kubernetes is vulnerable to OOM attack](https://github.com/kubernetes/kubernetes/issues/107325). This may be

content/en/docs/concepts/security/service-accounts.md

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ implementing identity-based security policies.
2626
Service accounts exist as ServiceAccount objects in the API server. Service
2727
accounts have the following properties:
2828

29-
* **Namespaced:** Each service account is bound to a Kubernetes
30-
{{<glossary_tooltip text="namespace" term_id="namespace">}}. Every namespace
31-
gets a [`default` ServiceAccount](#default-service-accounts) upon creation.
29+
* **Namespaced:** Each service account is bound to a Kubernetes
30+
{{<glossary_tooltip text="namespace" term_id="namespace">}}. Every namespace
31+
gets a [`default` ServiceAccount](#default-service-accounts) upon creation.
3232

33-
* **Lightweight:** Service accounts exist in the cluster and are
34-
defined in the Kubernetes API. You can quickly create service accounts to
35-
enable specific tasks.
33+
* **Lightweight:** Service accounts exist in the cluster and are
34+
defined in the Kubernetes API. You can quickly create service accounts to
35+
enable specific tasks.
3636

37-
* **Portable:** A configuration bundle for a complex containerized workload
38-
might include service account definitions for the system's components. The
39-
lightweight nature of service accounts and the namespaced identities make
40-
the configurations portable.
37+
* **Portable:** A configuration bundle for a complex containerized workload
38+
might include service account definitions for the system's components. The
39+
lightweight nature of service accounts and the namespaced identities make
40+
the configurations portable.
4141

4242
Service accounts are different from user accounts, which are authenticated
4343
human users in the cluster. By default, user accounts don't exist in the Kubernetes
@@ -78,10 +78,10 @@ the following scenarios:
7878

7979
* Your Pods need to communicate with the Kubernetes API server, for example in
8080
situations such as the following:
81-
* Providing read-only access to sensitive information stored in Secrets.
82-
* Granting [cross-namespace access](#cross-namespace), such as allowing a
83-
Pod in namespace `example` to read, list, and watch for Lease objects in
84-
the `kube-node-lease` namespace.
81+
* Providing read-only access to sensitive information stored in Secrets.
82+
* Granting [cross-namespace access](#cross-namespace), such as allowing a
83+
Pod in namespace `example` to read, list, and watch for Lease objects in
84+
the `kube-node-lease` namespace.
8585
* Your Pods need to communicate with an external service. For example, a
8686
workload Pod requires an identity for a commercially available cloud API,
8787
and the commercial provider allows configuring a suitable trust relationship.
@@ -92,7 +92,6 @@ the following scenarios:
9292
ServiceAccount identity of different Pods to group those Pods into different
9393
contexts.
9494

95-
9695
## How to use service accounts {#how-to-use}
9796

9897
To use a Kubernetes service account, you do the following:
@@ -101,7 +100,7 @@ To use a Kubernetes service account, you do the following:
101100
client like `kubectl` or a manifest that defines the object.
102101
1. Grant permissions to the ServiceAccount object using an authorization
103102
mechanism such as
104-
[RBAC](https://kubernetes.io/docs/reference/access-authn-authz/rbac/).
103+
[RBAC](/docs/reference/access-authn-authz/rbac/).
105104
1. Assign the ServiceAccount object to Pods during Pod creation.
106105

107106
If you're using the identity from an external service,
@@ -147,7 +146,7 @@ API and mounts the token as a
147146

148147
By default, Kubernetes provides the Pod
149148
with the credentials for an assigned ServiceAccount, whether that is the
150-
`default` ServiceAccount or a custom ServiceAccount that you specify.
149+
`default` ServiceAccount or a custom ServiceAccount that you specify.
151150

152151
To prevent Kubernetes from automatically injecting
153152
credentials for a specified ServiceAccount or the `default` ServiceAccount, set the
@@ -210,11 +209,11 @@ acting as a ServiceAccount tries to communicate with the Kubernetes API server,
210209
the client includes an `Authorization: Bearer <token>` header with the HTTP
211210
request. The API server checks the validity of that bearer token as follows:
212211

213-
1. Check the token signature.
214-
1. Check whether the token has expired.
215-
1. Check whether object references in the token claims are currently valid.
216-
1. Check whether the token is currently valid.
217-
1. Check the audience claims.
212+
1. Checks the token signature.
213+
1. Checks whether the token has expired.
214+
1. Checks whether object references in the token claims are currently valid.
215+
1. Checks whether the token is currently valid.
216+
1. Checks the audience claims.
218217

219218
The TokenRequest API produces _bound tokens_ for a ServiceAccount. This
220219
binding is linked to the lifetime of the client, such as a Pod, that is acting
@@ -257,15 +256,15 @@ used in your application and nowhere else.
257256
[Webhook Token Authentication](/docs/reference/access-authn-authz/authentication/#webhook-token-authentication)
258257
to validate bearer tokens using your own validation service.
259258
* Provide your own identities to Pods.
260-
* [Use the SPIFFE CSI driver plugin to provide SPIFFE SVIDs as X.509 certificate pairs to Pods](https://cert-manager.io/docs/projects/csi-driver-spiffe/).
259+
* [Use the SPIFFE CSI driver plugin to provide SPIFFE SVIDs as X.509 certificate pairs to Pods](https://cert-manager.io/docs/projects/csi-driver-spiffe/).
261260
{{% thirdparty-content single="true" %}}
262-
* [Use a service mesh such as Istio to provide certificates to Pods](https://istio.io/latest/docs/tasks/security/cert-management/plugin-ca-cert/).
261+
* [Use a service mesh such as Istio to provide certificates to Pods](https://istio.io/latest/docs/tasks/security/cert-management/plugin-ca-cert/).
263262
* Authenticate from outside the cluster to the API server without using service account tokens:
264-
* [Configure the API server to accept OpenID Connect (OIDC) tokens from your identity provider](/docs/reference/access-authn-authz/authentication/#openid-connect-tokens).
265-
* Use service accounts or user accounts created using an external Identity
266-
and Access Management (IAM) service, such as from a cloud provider, to
267-
authenticate to your cluster.
268-
* [Use the CertificateSigningRequest API with client certificates](/docs/tasks/tls/managing-tls-in-a-cluster/).
263+
* [Configure the API server to accept OpenID Connect (OIDC) tokens from your identity provider](/docs/reference/access-authn-authz/authentication/#openid-connect-tokens).
264+
* Use service accounts or user accounts created using an external Identity
265+
and Access Management (IAM) service, such as from a cloud provider, to
266+
authenticate to your cluster.
267+
* [Use the CertificateSigningRequest API with client certificates](/docs/tasks/tls/managing-tls-in-a-cluster/).
269268
* [Configure the kubelet to retrieve credentials from an image registry](/docs/tasks/administer-cluster/kubelet-credential-provider/).
270269
* Use a Device Plugin to access a virtual Trusted Platform Module (TPM), which
271270
then allows authentication using a private key.

0 commit comments

Comments
 (0)