Skip to content

Containers and serverlessService 13 of 1310 controls

Amazon EKS security hardening

Harden Amazon EKS: private API endpoint, access entries, Pod Identity, IMDS hop limit, KMS envelope encryption, audit logs, Pod Security Standards and upgrades.

Published on 11 min readTags:#kubernetes#containers#iam
On this page

Amazon EKS runs the Kubernetes control plane for you, but almost everything that decides whether a cluster is secure stays your job: who can reach the API server, how IAM principals map to Kubernetes permissions, what AWS credentials a pod can obtain, and what a pod is allowed to do on its node. At defaults, a new cluster has a public API endpoint, nodes whose instance role is reachable from every pod through the metadata service, and no pod security or network policy at all. Real compromises follow that path: an exposed or vulnerable application pod, then the node role credentials through IMDS, then the AWS account. Cryptomining groups such as TeamTNT built tooling specifically to harvest cloud credentials from Kubernetes nodes, and public research (including Wiz's EKS Cluster Games) walks through the same chain. This page covers the AWS-side and Kubernetes-side controls that close it.

Baseline controls

10 controlsCIS numbers refer to the CIS AWS Foundations Benchmark v7.1.0 unless another CIS benchmark is named; Security Hub CSPM IDs are listed where a control exists.
  1. 01API endpoint private, or public limited by CIDR

    An internet facing API server is one leaked kubeconfig or token away from takeover.

    How to check: aws eks describe-cluster --name prod --query cluster.resourcesVpcConfig
    Mapping: EKS.1
  2. 02Access entries (API mode) instead of aws-auth

    IAM-managed access is auditable and survives a broken or tampered ConfigMap.

    How to check: aws eks describe-cluster --name prod --query cluster.accessConfig
  3. 03Pods use Pod Identity or IRSA, not the node role

    Without it every pod on a node inherits the node role's AWS permissions.

    How to check: aws eks list-pod-identity-associations --cluster-name prod
  4. 04IMDSv2 required with hop limit 1 on nodes

    Stops pods from reaching the node's instance metadata credentials.

    How to check: aws ec2 describe-launch-template-versions --launch-template-id lt-0abc
  5. 05Envelope encryption with a customer managed KMS key

    You control the key policy and see every decrypt of Kubernetes secrets in CloudTrail.

    How to check: aws eks describe-cluster --name prod --query cluster.encryptionConfig
  6. 06Control plane audit logging enabled

    Audit logs are the only record of who did what through the Kubernetes API.

    How to check: aws eks describe-cluster --name prod --query cluster.logging
    Mapping: EKS.8
  7. 07Pod Security Standards enforced per namespace

    Blocks privileged, hostPath and host network pods that lead straight to the node.

    How to check: kubectl get ns -L pod-security.kubernetes.io/enforce
  8. 08Default deny network policies

    Without them any compromised pod can reach every other pod in the cluster.

    How to check: kubectl get networkpolicy -A
  9. 09Clusters and node groups on standard support versions

    Older versions miss security fixes and features; extended support costs extra.

    How to check: aws eks describe-cluster --name prod --query cluster.version
    Mapping: EKS.2, EKS.9
  10. 10GuardDuty EKS Protection and Runtime Monitoring on

    Detects anonymous access, privileged pods, exec into kube-system and miners.

    How to check: aws guardduty get-detector --detector-id <id> --query Features

Restrict the cluster API endpoint

The Kubernetes API server endpoint is public by default. Authentication still applies, but a public endpoint means a stolen kubeconfig, a leaked service account token or a future API server vulnerability is exploitable from anywhere. Security Hub CSPM control EKS.1 fails when the endpoint is publicly accessible.

The best option is private only: enable private access, disable public access, and reach the API from inside the VPC (CI runners in the VPC, a bastion via Session Manager, or a VPN).

aws eks update-cluster-config \
  --name prod \
  --resources-vpc-config endpointPrivateAccess=true,endpointPublicAccess=false

If you must keep the public endpoint, enable private access as well (so node and pod traffic stays inside the VPC) and restrict the public side to known CIDR blocks:

aws eks update-cluster-config \
  --name prod \
  --resources-vpc-config endpointPrivateAccess=true,endpointPublicAccess=true,publicAccessCidrs="203.0.113.0/24"

With CIDR restrictions the cluster still fails EKS.1, which only checks whether public access is on. Document the exception and suppress the finding deliberately.

Verify

aws eks describe-cluster --name prod \
  --query 'cluster.resourcesVpcConfig.[endpointPublicAccess,endpointPrivateAccess,publicAccessCidrs]'

Also check the cluster security group: it should accept 443 only from node security groups and your admin network, never from 0.0.0.0/0.

Manage access with EKS access entries

Historically, IAM principals were mapped to Kubernetes users and groups through the aws-auth ConfigMap in kube-system. That ConfigMap is fragile (a YAML mistake locks everyone out), invisible to IAM tooling, and editable by anyone with write access to kube-system, which makes it a persistence target. The IAM principal that created the cluster also used to keep invisible system:masters access forever.

EKS access entries move that mapping into the EKS API. You create an access entry per IAM principal and associate EKS access policies (or Kubernetes groups bound with RBAC) scoped to the cluster or to namespaces. Changes are IAM-authorized and logged in CloudTrail.

# Move the cluster to API mode (API_AND_CONFIG_MAP first if you are migrating)
aws eks update-cluster-config --name prod \
  --access-config authenticationMode=API_AND_CONFIG_MAP

# Grant a platform team role cluster admin
aws eks create-access-entry --cluster-name prod \
  --principal-arn arn:aws:iam::111122223333:role/platform-admins

aws eks associate-access-policy --cluster-name prod \
  --principal-arn arn:aws:iam::111122223333:role/platform-admins \
  --policy-arn arn:aws:eks::aws:cluster-access-policy/AmazonEKSClusterAdminPolicy \
  --access-scope type=cluster

# Give a developer role view access to one namespace only
aws eks associate-access-policy --cluster-name prod \
  --principal-arn arn:aws:iam::111122223333:role/team-a-dev \
  --policy-arn arn:aws:eks::aws:cluster-access-policy/AmazonEKSViewPolicy \
  --access-scope type=namespace,namespaces=team-a

Once every principal from aws-auth has an access entry, switch to authenticationMode=API. The change is one way: once the ConfigMap method is off it cannot be turned back on, so neither API_AND_CONFIG_MAP nor CONFIG_MAP is available afterwards. Test with API_AND_CONFIG_MAP first. For new clusters, set bootstrapClusterCreatorAdminPermissions=false in the access configuration and grant admin explicitly to a role, not to whoever ran the pipeline.

Verify

aws eks list-access-entries --cluster-name prod
aws eks list-associated-access-policies --cluster-name prod \
  --principal-arn arn:aws:iam::111122223333:role/platform-admins

Review who holds AmazonEKSClusterAdminPolicy; it should be a short list of roles assumed through IAM Identity Center, not users with access keys.

Give pods their own IAM roles

Every EC2 node has an instance role with the permissions the kubelet and CNI need (pulling from ECR, managing ENIs). If pods get AWS credentials by falling through to that node role, every workload on the node shares it, and a single compromised pod can call EC2 and ECR APIs as the node. Teams then widen the node role for one application, and every pod inherits that too.

EKS Pod Identity is the current recommended mechanism. You install the Pod Identity Agent add-on, create an IAM role that trusts pods.eks.amazonaws.com, and associate it with a namespace and service account:

aws eks create-addon --cluster-name prod --addon-name eks-pod-identity-agent

aws eks create-pod-identity-association \
  --cluster-name prod \
  --namespace payments \
  --service-account payments-api \
  --role-arn arn:aws:iam::111122223333:role/eks/payments-api

The role's trust policy:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": { "Service": "pods.eks.amazonaws.com" },
      "Action": ["sts:AssumeRole", "sts:TagSession"]
    }
  ]
}

Pod Identity attaches session tags (cluster name, namespace, service account) so one role can be reused with ABAC conditions such as aws:PrincipalTag/kubernetes-namespace. IAM Roles for Service Accounts (IRSA), based on the cluster OIDC provider, remains supported and is still needed on Fargate, Outposts and some older add-ons. With IRSA, always pin the sub condition to system:serviceaccount:<namespace>:<name> in the trust policy; a trust policy that only checks aud lets any service account in the cluster assume the role.

Keep the node role minimal: AmazonEKSWorkerNodePolicy, AmazonEC2ContainerRegistryReadOnly, and (only if the VPC CNI does not use its own Pod Identity or IRSA role) AmazonEKS_CNI_Policy.

Block pod access to instance metadata

Pod Identity does not stop a pod from asking IMDS for the node role's credentials. Close that path at the node: require IMDSv2 and set the PUT response hop limit to 1 in the node launch template. With a hop limit of 1, the IMDSv2 token response cannot cross the extra network hop into a pod's network namespace, so pods that do not use host networking cannot get a token.

aws ec2 create-launch-template-version \
  --launch-template-id lt-0abc1234def567890 \
  --source-version 1 \
  --launch-template-data '{"MetadataOptions":{"HttpTokens":"required","HttpPutResponseHopLimit":1,"HttpEndpoint":"enabled"}}'

Then roll the managed node group to the new launch template version. Pods that use hostNetwork: true can still reach IMDS, which is one more reason to block host networking with Pod Security Standards. Some components (older AWS Load Balancer Controller or CNI configurations, agents that discover their Region through IMDS) need explicit configuration of Region and VPC ID once IMDS is blocked; test in a staging node group first. The EC2 page covers IMDSv2 enforcement in depth.

Encrypt Kubernetes secrets with your own KMS key

Since Kubernetes 1.28, EKS applies envelope encryption to all Kubernetes API data stored in etcd by default, using KMS v2 and an AWS owned key. That protects against storage-level exposure but gives you no control or visibility. Associating a customer managed KMS key moves the key encryption key into your account: the key policy decides who (and which cluster) can use it, and decrypt activity appears in CloudTrail.

aws eks associate-encryption-config \
  --cluster-name prod \
  --encryption-config '[{"resources":["secrets"],"provider":{"keyArn":"arn:aws:kms:eu-west-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"}}]'

The resources field is kept for backward compatibility; with a customer managed key, the same key protects all Kubernetes API data, not only Secrets. Once associated, the key cannot be removed from the cluster.

Note: Disabling or deleting that key breaks the cluster. Without the key the API server cannot start after a restart, and a deleted key or revoked grant makes the cluster unrecoverable. Protect the key with a key policy that denies kms:DisableKey and kms:ScheduleKeyDeletion to everyone except a break glass role, as described on the KMS page.

Envelope encryption protects etcd, not the Secret value as seen through the API: anyone with get secrets RBAC permission still reads it in plaintext. Keep RBAC on Secrets tight, and for high value credentials use the Secrets Store CSI Driver with AWS Secrets Manager so the secret never becomes a Kubernetes object.

Enable control plane logging

EKS can send five control plane log types to CloudWatch Logs: api, audit, authenticator, controllerManager and scheduler. None is enabled by default. Security Hub CSPM control EKS.8 checks that audit logging is on. Enable at least audit and authenticator (the latter records which IAM principal authenticated as which Kubernetes identity):

aws eks update-cluster-config --name prod \
  --logging '{"clusterLogging":[{"types":["api","audit","authenticator","controllerManager","scheduler"],"enabled":true}]}'

Logs land in /aws/eks/prod/cluster. Set a retention period on that log group and, for long-term storage, subscribe it to your central logging account.

Enforce Pod Security Standards

PodSecurityPolicy was removed in Kubernetes 1.25. Its built-in replacement, Pod Security Admission, enforces the Pod Security Standards (privileged, baseline, restricted) through namespace labels. restricted blocks privileged containers, host namespaces, hostPath volumes, running as root and privilege escalation, which are the primitives that turn a pod compromise into node compromise.

kubectl label namespace payments \
  pod-security.kubernetes.io/enforce=restricted \
  pod-security.kubernetes.io/enforce-version=latest \
  pod-security.kubernetes.io/warn=restricted \
  pod-security.kubernetes.io/audit=restricted

Roll out with warn and audit first, fix workloads, then add enforce. Keep privileged only on system namespaces that genuinely need it (CNI, storage drivers, monitoring agents). For policies beyond the standards (approved registries, required labels, no latest tags), add an admission controller such as Kyverno or OPA Gatekeeper.

Verify

kubectl get namespaces -L pod-security.kubernetes.io/enforce

Any application namespace with an empty value has no enforcement.

Apply network policies

Kubernetes networking is flat by default: every pod can reach every other pod and service in the cluster. The Amazon VPC CNI can enforce Kubernetes NetworkPolicy objects natively once you turn the feature on:

aws eks update-addon --cluster-name prod --addon-name vpc-cni \
  --configuration-values '{"enableNetworkPolicy":"true"}'

Start each namespace with a default deny, then allow the flows the application needs, including DNS to CoreDNS:

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: default-deny
  namespace: payments
spec:
  podSelector: {}
  policyTypes: ["Ingress", "Egress"]

For traffic leaving the cluster to AWS resources, security groups for pods give per-pod security groups enforced at the ENI level, which RDS and other security groups can reference.

Keep a regular upgrade cadence

Each Kubernetes minor version gets 14 months of standard support on EKS, followed by 12 months of extended support at an additional hourly cost per cluster. Extended support versions still get patches for critical and important vulnerabilities, but not lower-severity fixes, non-security bug fixes or new security features. Security Hub CSPM controls EKS.2 (clusters) and EKS.9 (node groups) fail for versions outside standard support.

Plan one minor version upgrade roughly every four months to stay inside standard support: control plane first, then add-ons (VPC CNI, CoreDNS, kube-proxy, Pod Identity Agent), then node groups. Check for removed APIs before each step with EKS upgrade insights:

aws eks list-insights --cluster-name prod
aws eks update-cluster-version --name prod --kubernetes-version <next-minor>

If you do not want extended support charges or long-lived old versions, set the cluster upgrade policy to STANDARD so EKS upgrades it automatically at the end of standard support. Managed node groups also need AMI updates between minor versions for OS and kubelet patches.

Benchmark with kube-bench

The CIS Amazon EKS Benchmark covers the node and Kubernetes configuration that AWS does not manage. Run Aqua Security's kube-bench as a Job on a node with the EKS profile:

kubectl apply -f https://raw.githubusercontent.com/aquasecurity/kube-bench/main/job-eks.yaml
kubectl logs job/kube-bench

Control plane checks do not apply on EKS (you cannot reach the managed masters); focus on the worker node and policy sections. Prowler covers the AWS-side EKS configuration in the same report as the rest of the account.

Logging and detection

Collect three layers:

  • CloudTrail management events for the EKS API: CreateAccessEntry, AssociateAccessPolicy, UpdateClusterConfig, CreatePodIdentityAssociation, AssociateEncryptionConfig and DeleteCluster. These change who can reach and control the cluster.
  • Control plane audit logs in CloudWatch Logs for activity inside Kubernetes: Secret reads, pods/exec, RoleBinding and ClusterRoleBinding changes, requests from system:anonymous.
  • Node and container telemetry from GuardDuty Runtime Monitoring or your EDR.

An EventBridge rule for access changes:

{
  "source": ["aws.eks"],
  "detail-type": ["AWS API Call via CloudTrail"],
  "detail": {
    "eventName": [
      "CreateAccessEntry",
      "AssociateAccessPolicy",
      "UpdateClusterConfig",
      "CreatePodIdentityAssociation"
    ]
  }
}

The CloudTrail page covers the organization trail these rules depend on.

GuardDuty EKS Protection and Runtime Monitoring

GuardDuty EKS Protection analyzes the cluster audit logs directly from the EKS control plane (you do not need to enable audit logging for it), and Runtime Monitoring adds an agent on nodes that sees process, file and network activity. Enable both from the delegated administrator, with automated agent management so new clusters get the add-on:

aws guardduty update-detector --detector-id <detector-id> \
  --features '[{"Name":"EKS_AUDIT_LOGS","Status":"ENABLED"},{"Name":"RUNTIME_MONITORING","Status":"ENABLED","AdditionalConfiguration":[{"Name":"EKS_ADDON_MANAGEMENT","Status":"ENABLED"}]}]'

Findings to route to on call include Policy:Kubernetes/AnonymousAccessGranted, Discovery:Kubernetes/SuccessfulAnonymousAccess, PrivilegeEscalation:Kubernetes/AnomalousBehavior.WorkloadDeployed!PrivilegedContainer, Execution:Kubernetes/ExecInKubeSystemPod and the CryptoCurrency:Runtime/ family. Runtime Monitoring needs the VPC endpoint GuardDuty creates (or that you create) in each cluster VPC. The GuardDuty page covers organization-wide enablement.

Common mistakes

  • Public endpoint because "it still needs credentials". Credentials leak, and Kubernetes RBAC mistakes such as binding system:anonymous or system:unauthenticated have exposed clusters directly. Make the endpoint private or CIDR restricted.
  • Widening the node role for one application. Every pod on every node in that group inherits the permission. Use Pod Identity or IRSA and leave the node role at its managed policies.
  • IRSA trust policies without a sub condition. Any service account in the cluster, including one an attacker creates, can then assume the role.
  • Hop limit 2 on nodes "for compatibility". That single setting lets every pod fetch node credentials from IMDS. Fix the components that need IMDS instead.
  • Leaving the cluster creator as an invisible admin. On older clusters the creator keeps system:masters outside aws-auth. Move to access entries and review the creator's access.
  • No audit logging until after an incident. EKS.8 exists for a reason: without audit logs you cannot tell which identity read Secrets or exec'd into pods.
  • Treating Secrets encryption as access control. Envelope encryption protects etcd storage; RBAC decides who reads Secret values.
  • Letting clusters slide into extended support. It costs more, delays security features, and turns upgrades into multi-version migrations.

References

Written by

Florian Amette

Security engineer writing practical, benchmark-aligned hardening baselines for AWS services, from the organization and identities to data, networks and workloads.

Related services

All services