01 Run list-clusters command (OSX/Linux/UNIX) using custom query filters to list the names of all AWS EKS clusters available in the selected region:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
aws eks list-clusters
--region us-east-1
--output table
--query 'clusters'
02 The command output should return a table with the requested EKS cluster names:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
-------------------------
| ListClusters |
+-----------------------+
| cc-eks-prod-stack |
| cc-eks-mobile-app |
+-----------------------+
03 Run describe-cluster command (OSX/Linux/UNIX) using the name of the EKS cluster that you want to examine as identifier parameter and custom query filters to get the ID(s) of the security group(s) associated with the selected Amazon EKS cluster:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
aws eks describe-cluster
--region us-east-1
--name cc-eks-prod-stack
--query 'cluster.resourcesVpcConfig.securityGroupIds'
04 The command output should return the requested security group identifiers (IDs):
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
[
"sg-0abcd1234abcd1234"
]
05 Run describe-security-groups command (OSX/Linux/UNIX) using the name of the EKS security group that you want to examine as identifier parameter and custom query filters to expose the configuration of the inbound rule(s) defined for the selected security group:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
aws ec2 describe-security-groups
--region us-east-1
--group-ids sg-0abcd1234abcd1234
--query 'SecurityGroups[*].IpPermissions'
06 The command output should return the requested configuration information:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
[
[
{
"PrefixListIds": [],
"FromPort": 22,
"IpRanges": [
{
"CidrIp": "0.0.0.0/0"
}
],
"ToPort": 22,
"IpProtocol": "tcp",
"UserIdGroupPairs": [],
"Ipv6Ranges": []
},
{
"PrefixListIds": [],
"FromPort": 443,
"IpRanges": [
{
"CidrIp": "0.0.0.0/0"
}
],
"ToPort": 443,
"IpProtocol": "tcp",
"UserIdGroupPairs": [],
"Ipv6Ranges": []
}
]
]
Check
FromPort and
ToPort attributes values (highlighted) available for each inbound/ingress rule returned by the
describe-security-groups command output. If one or more inbound rules are configured to allow access on ports different than TCP port 443 (HTTPS), as shown in the output example above, the access configuration for the selected Amazon EKS security group is not compliant.
07 Repeat step no. 5 and 6 to check the access configuration (i.e. opened ports) for the rest of the security groups associated with the selected EKS cluster.
08 Repeat steps no. 3 – 7 to verify the EKS security group access compliance for other Amazon EKS clusters available in the selected region.
09 Change the AWS region by updating the --region command parameter value and repeat steps no. 1 – 8 to perform the audit process for other regions.