Skip to content

Commit ab22b74

Browse files
authored
Merge pull request #298 from cblopez/patch-1
Added access entry abuse to pivot from AWS to Kubernetes
2 parents 45e5386 + 97af0f5 commit ab22b74

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

  • src/pentesting-cloud/aws-security/aws-post-exploitation/aws-eks-post-exploitation

src/pentesting-cloud/aws-security/aws-post-exploitation/aws-eks-post-exploitation/README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ users:
8080
8181
The **creator** of the **EKS cluster** is **ALWAYS** going to be able to get into the kubernetes cluster part of the group **`system:masters`** (k8s admin). At the time of this writing there is **no direct way** to find **who created** the cluster (you can check CloudTrail). And the is **no way** to **remove** that **privilege**.
8282

83-
The way to grant **access to over K8s to more AWS IAM users or roles** is using the **configmap** **`aws-auth`**.
83+
#### Abusing configmap
84+
85+
The traditional way to grant **access to over K8s to more AWS IAM users or roles** is using the **configmap** **`aws-auth`**.
8486

8587
> [!WARNING]
8688
> Therefore, anyone with **write access** over the config map **`aws-auth`** will be able to **compromise the whole cluster**.
@@ -89,6 +91,30 @@ For more information about how to **grant extra privileges to IAM roles & users*
8991

9092
Check also[ **this awesome**](https://blog.lightspin.io/exploiting-eks-authentication-vulnerability-in-aws-iam-authenticator) **post to learn how the authentication IAM -> Kubernetes work**.
9193

94+
#### Abusing Access Entries
95+
96+
AWS implementes an additional way to grant IAM users access to the Kubernetes cluster through access entries. If you have the `eks:CreateAccessEntry` and `eks:AssociateAccessPolicy` permissions, you may also be able to assign a Kubernetes administrator role to either your user or a specific rol.
97+
98+
First, **create an access entry for your user or role**:
99+
100+
```
101+
aws eks create-access-entry --cluster-name <cluster_name> --region <region> --principal-arn <arn_from_your_user_or_role> --type STANDARD
102+
```
103+
104+
With that entry created, you may now be able to assign a policy directly to it. There is a built-in AWS policy called *AmazonEKSClusterAdminPolicy* that may be used directly. Keep in mind that if your environment has some other custom policies that also grant elevated privileges in EKS, you may change the `--policy-arn` to any of those:
105+
106+
```
107+
aws eks associate-access-policy --cluster-name <cluster_name> --region <region> --principal-arn <arn_from_your_user_or_role> --policy-arn arn:aws:eks::aws:cluster-access-policy/AmazonEKSClusterAdminPolicy --access-scope type=cluster
108+
```
109+
110+
You can search for this policy in AWS official documentation [**here**](https://docs.aws.amazon.com/eks/latest/userguide/access-policy-permissions.html#access-policy-permissions-amazoneksclusteradminpolicy)
111+
112+
From this point on, you may now be able to request a *k8s* token and interact with the cluster as an administrator:
113+
114+
```
115+
aws eks get-token --cluster-name <cluster_name> --output json | jq -r '.status.token'
116+
```
117+
92118
### From Kubernetes to AWS
93119

94120
It's possible to allow an **OpenID authentication for kubernetes service account** to allow them to assume roles in AWS. Learn how [**this work in this page**](../../../kubernetes-security/kubernetes-pivoting-to-clouds.md#workflow-of-iam-role-for-service-accounts-1).

0 commit comments

Comments
 (0)