01 Run DescribeSecurityGroups command (OSX/Linux/UNIX) to describe the information available for each ECS security group provisioned in the specified cloud region:
aliyun ecs DescribeSecurityGroups --RegionId 'eu-west-1'
02 The command output should return the requested details (including the security group ID):
{
"SecurityGroups": {
"SecurityGroup": [
{
"CreationTime": "2024-02-24T17:42:55Z",
"Description": "",
"SecurityGroupId": "sg-abcd1234abcd1234abcd",
"SecurityGroupName": "sg-abcd1234abcd1234abcd",
"SecurityGroupType": "normal",
"ServiceManaged": false,
"VpcId": "vpc-123456789012345678901"
},
{
"CreationTime": "2024-02-23T17:52:37Z",
"Description": "",
"SecurityGroupId": "sg-1234abcd1234abcd1234",
"SecurityGroupName": "sg-1234abcd1234abcd1234",
"SecurityGroupType": "normal",
"ServiceManaged": false,
"VpcId": "vpc-123456789012345678901"
}
]
},
"TotalCount": 2,
"PageNumber": 1,
"PageSize": 10,
"RegionId": "eu-west-1",
"RequestId": "ABCDABCD-1234-ABCD-1234-ABCD1234ABCD"
}
03 Run DescribeSecurityGroupAttribute command (OSX/Linux/UNIX) using the ID of the ECS security group that you want to examine as the identifier parameter, to describe the inbound rules defined for the selected security group:
aliyun ecs DescribeSecurityGroupAttribute
--RegionId 'eu-west-1'
--SecurityGroupId 'sg-abcd1234abcd1234abcd'
--Direction ingress
04 The command output should return the requested configuration information:
{
"Description": "System created security group.",
"InnerAccessPolicy": "Accept",
"Permissions": {
"Permission": [
{
"CreateTime": "2024-02-23T17:52:37Z",
"Description": "System created rule.",
"DestCidrIp": "",
"DestGroupId": "",
"DestGroupName": "",
"DestGroupOwnerAccount": "",
"DestPrefixListId": "",
"DestPrefixListName": "",
"Direction": "ingress",
"IpProtocol": "TCP",
"Ipv6DestCidrIp": "",
"Ipv6SourceCidrIp": "",
"NicType": "intranet",
"Policy": "Accept",
"PortRange": "22/22",
"Priority": 100,
"SecurityGroupRuleId": "sgr-123456789012345678901",
"SourceCidrIp": "0.0.0.0/0",
"SourceGroupId": "",
"SourceGroupName": "",
"SourceGroupOwnerAccount": "",
"SourcePortRange": "",
"SourcePrefixListId": "",
"SourcePrefixListName": ""
},
{
"CreateTime": "2024-02-23T17:52:37Z",
"Description": "System created rule.",
"DestCidrIp": "",
"DestGroupId": "",
"DestGroupName": "",
"DestGroupOwnerAccount": "",
"DestPrefixListId": "",
"DestPrefixListName": "",
"Direction": "ingress",
"IpProtocol": "TCP",
"Ipv6DestCidrIp": "",
"Ipv6SourceCidrIp": "",
"NicType": "intranet",
"Policy": "Accept",
"PortRange": "80/80",
"Priority": 100,
"SecurityGroupRuleId": "sgr-1234567890abcdabcdabcd",
"SourceCidrIp": "0.0.0.0/0",
"SourceGroupId": "",
"SourceGroupName": "",
"SourceGroupOwnerAccount": "",
"SourcePortRange": "",
"SourcePrefixListId": "",
"SourcePrefixListName": ""
}
]
},
"RegionId": "eu-west-1",
"RequestId": "ABCDABCD-1234-ABCD-1234-ABCD1234ABCD",
"SecurityGroupId": "sg-abcd1234abcd1234abcd",
"SecurityGroupName": "sg-abcd1234abcd1234abcd",
"VpcId": "vpc-123456789012345678901"
}
Check the inbound rules listed within the
"Permission" array for any rules with the
"IpProtocol" attribute set to
"TCP",
"PortRange" set to
"22/22" or
"1/65535", and the
"SourceCidrIp" set to
"0.0.0.0/0". If one or more rules match the search criteria, there are inbound rules that allow unrestricted access on TCP port 22, therefore the SSH access to the associated ECS instances is not secured.
05 Repeat steps no. 3 and 4 for each ECS security group available within the selected cloud region.
06 Change the cloud region by updating the --RegionId command parameter value and repeat the Audit process for other regions.