Skip to content

Commit 2f0fc3f

Browse files
committed
Document permissions needed in AWS and K8s
1 parent 3c359ae commit 2f0fc3f

File tree

2 files changed

+96
-2
lines changed

2 files changed

+96
-2
lines changed

cmd/managed-kubernetes-auditing-toolkit/eks/role_relationships.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func buildEksRoleRelationshipsCommand() *cobra.Command {
5454
cluster = eksClusterName
5555
}
5656
if cluster == "" {
57-
return errors.New("unable to determine your current EKS cluster name")
57+
return errors.New("unable to determine your current EKS cluster name. Try specifying it explicitely with the --eks-cluster-name flag")
5858
}
5959
return doFindRoleRelationshipsCommand(cluster)
6060
},
@@ -63,7 +63,7 @@ func buildEksRoleRelationshipsCommand() *cobra.Command {
6363
eksRoleRelationshipsCommand.Flags().StringVarP(&outputFormat, "output-format", "f", DefaultOutputFormat, "Output format. Supported formats: "+strings.Join(availableOutputFormats, ", "))
6464
eksRoleRelationshipsCommand.Flags().StringVarP(&outputFile, "output-file", "o", "", "Output file. If not specified, output will be printed to stdout.")
6565
eksRoleRelationshipsCommand.Flags().StringVarP(&eksClusterName, "eks-cluster-name", "", "", "When the EKS cluster name cannot be automatically detected from your KubeConfig, specify this argument to pass the EKS cluster name of your current kubectl context")
66-
66+
6767
return eksRoleRelationshipsCommand
6868
}
6969

permissions.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Permissions needed to run MKAT
2+
3+
To be able to run MKAT and benefit from all its features, you need the following permissions.
4+
5+
## AWS permissions
6+
7+
```json
8+
{
9+
"Version": "2012-10-17",
10+
"Statement": [
11+
{
12+
"Effect": "Allow",
13+
"Action": [
14+
"eks:DescribeCluster",
15+
"iam:ListRoles"
16+
],
17+
"Resource": "*"
18+
}
19+
]
20+
}
21+
```
22+
23+
Optionally, you can restrict `eks:DescribeCluster` to the specific EKS cluster you want to analyze, e.g.
24+
25+
```json
26+
{
27+
"Version": "2012-10-17",
28+
"Statement": [
29+
{
30+
"Effect": "Allow",
31+
"Action": [
32+
"eks:DescribeCluster"
33+
],
34+
"Resource": "arn:aws:eks:us-east-1:012345678901:cluster/your-eks-cluster"
35+
},
36+
{
37+
"Effect": "Allow",
38+
"Action": [
39+
"iam:ListRoles"
40+
],
41+
"Resource": "*"
42+
}
43+
]
44+
}
45+
```
46+
47+
## Kubernetes permissions
48+
49+
You will need a `ClusterRole` with the following permissions:
50+
51+
```yaml
52+
apiVersion: rbac.authorization.k8s.io/v1
53+
kind: ClusterRole
54+
metadata:
55+
name: mkat
56+
rules:
57+
# mkat eks find-role-relationships
58+
- apiGroups: [""]
59+
resources: ["serviceaccounts", "pods"]
60+
verbs: ["list"]
61+
# mkat eks find-secrets
62+
- apiGroups: [""]
63+
resources: ["pods", "secrets", "configmaps"]
64+
verbs: ["list"]
65+
# mkat eks test-imds
66+
- apiGroups: [""]
67+
resources: ["pods"]
68+
verbs: ["list", "get", "create", "delete"]
69+
- apiGroups: [""]
70+
resources: ["pods/log"]
71+
verbs: ["get"]
72+
```
73+
74+
In EKS, you can for instance bind this ClusterRole to a `mkat-users` group, then use the [`aws-auth`](https://securitylabs.datadoghq.com/articles/amazon-eks-attacking-securing-cloud-identities/#authorization-the-aws-auth-configmap) ConfigMap to assign the group to your AWS identity:
75+
76+
```bash
77+
kubectl create clusterrolebinding mkat --clusterrole=mkat --group=mkat-users
78+
```
79+
80+
```yaml
81+
apiVersion: v1
82+
kind: ConfigMap
83+
metadata:
84+
name: aws-auth
85+
namespace: kube-system
86+
data:
87+
mapRoles: |
88+
# ...
89+
- rolearn: arn:aws:iam::012345678901:role/your-role
90+
groups: ["mkat-users"]
91+
username: mkat-user:{{SessionName}}
92+
mapUsers: |
93+
[]
94+
```

0 commit comments

Comments
 (0)