|
| 1 | +// AWS CIS 1.2.0 Rule equivalent 4.3 |
| 2 | +export default { |
| 3 | + id: 'aws-cis-1.5.0-5.3', |
| 4 | + title: |
| 5 | + 'AWS CIS 5.3 Ensure the default security group of every VPC restricts all traffic', |
| 6 | + description: `A VPC comes with a default security group whose initial settings deny all inbound traffic, |
| 7 | + allow all outbound traffic, and allow all traffic between instances assigned to the security |
| 8 | + group. If you don't specify a security group when you launch an instance, the instance is |
| 9 | + automatically assigned to this default security group. Security groups provide stateful |
| 10 | + filtering of ingress/egress network traffic to AWS resources. It is recommended that the |
| 11 | + default security group restrict all traffic. |
| 12 | +
|
| 13 | + The default VPC in every region should have its default security group updated to comply. |
| 14 | + Any newly created VPCs will automatically contain a default security group that will need |
| 15 | + remediation to comply with this recommendation. |
| 16 | +
|
| 17 | + **NOTE:** When implementing this recommendation, VPC flow logging is invaluable in |
| 18 | + determining the least privilege port access required by systems to work properly because it |
| 19 | + can log all packet acceptances and rejections occurring under the current security groups. |
| 20 | + This dramatically reduces the primary barrier to least privilege engineering - discovering |
| 21 | + the minimum ports required by systems in the environment. Even if the VPC flow logging |
| 22 | + recommendation in this benchmark is not adopted as a permanent security measure, it |
| 23 | + should be used during any period of discovery and engineering for least privileged security |
| 24 | + groups.`, |
| 25 | + audit: `Perform the following to determine if the account is configured as prescribed: |
| 26 | + Security Group State |
| 27 | +
|
| 28 | + 1. Login to the AWS Management Console at https://console.aws.amazon.com/vpc/home |
| 29 | + 2. Repeat the next steps for all VPCs - including the default VPC in each AWS region: |
| 30 | + 3. In the left pane, click *Security Groups* |
| 31 | + 4. For each default security group, perform the following: |
| 32 | + 5. Select the *default* security group |
| 33 | + 6. Click the *Inbound Rules* tab |
| 34 | + 7. Ensure no rule exist |
| 35 | + 8. Click the *Outbound Rules* tab |
| 36 | + 9. Ensure no rules exist |
| 37 | +
|
| 38 | + Security Group Members |
| 39 | +
|
| 40 | + 1. Login to the AWS Management Console at https://console.aws.amazon.com/vpc/home |
| 41 | + 2. Repeat the next steps for all default groups in all VPCs - including the default VPC in each AWS region: |
| 42 | + 3. In the left pane, click *Security Groups* |
| 43 | + 4. Copy the id of the default security group. |
| 44 | + 5. Change to the EC2 Management Console at https://console.aws.amazon.com/ec2/v2/home |
| 45 | + 6. In the filter column type 'Security Group ID : < security group id from #4 >`, |
| 46 | + rationale: |
| 47 | + 'Configuring all VPC default security groups to restrict all traffic will encourage least privilege security group development and mindful placement of AWS resources into security groups which will, in turn, reduce the exposure of those resources.', |
| 48 | + remediation: `Security Group Members |
| 49 | + Perform the following to implement the prescribed state: |
| 50 | +
|
| 51 | + 1. Identify AWS resources that exist within the default security group |
| 52 | + 2. Create a set of least privilege security groups for those resources |
| 53 | + 3. Place the resources in those security groups |
| 54 | + 4. Remove the resources noted in #1 from the default security group |
| 55 | +
|
| 56 | + Security Group State |
| 57 | +
|
| 58 | + 1. Login to the AWS Management Console at https://console.aws.amazon.com/vpc/home |
| 59 | + 2. Repeat the next steps for all VPCs - including the default VPC in each AWS region: |
| 60 | + 3. In the left pane, click *Security Groups* |
| 61 | + 4. For each default security group, perform the following: |
| 62 | + 5. Select the *default* security group |
| 63 | + 6. Click the *Inbound Rules* tab |
| 64 | + 7. Remove any inbound rules |
| 65 | + 8. Click the *Outbound Rules* tab |
| 66 | + 9. Remove any inbound rules |
| 67 | +
|
| 68 | + Recommended: |
| 69 | + IAM groups allow you to edit the "name" field. After remediating default groups rules for all VPCs in all regions, edit this field to add text similar to "DO NOT USE. DO NOT ADD RULES"`, |
| 70 | + references: [ |
| 71 | + 'CCE-79201-0', |
| 72 | + 'http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html', |
| 73 | + 'CIS CSC v6.0 #9.2', |
| 74 | + ], |
| 75 | + gql: `{ |
| 76 | + queryawsSecurityGroup(filter: { name: { eq: "default" } }) { |
| 77 | + id |
| 78 | + name |
| 79 | + arn |
| 80 | + accountId |
| 81 | + __typename |
| 82 | + inboundRules{ |
| 83 | + source |
| 84 | + } |
| 85 | + outboundRules{ |
| 86 | + destination |
| 87 | + } |
| 88 | + } |
| 89 | + }`, |
| 90 | + exclude: { not: { path: '@.name', equal: 'default' } }, |
| 91 | + resource: 'queryawsSecurityGroup[*]', |
| 92 | + severity: 'high', |
| 93 | + conditions: { |
| 94 | + not: { |
| 95 | + or: [ |
| 96 | + { |
| 97 | + path: '@.inboundRules', |
| 98 | + array_any: { |
| 99 | + path: '[*].source', |
| 100 | + in: ['0.0.0.0/0', '::/0'], |
| 101 | + }, |
| 102 | + }, |
| 103 | + { |
| 104 | + path: '@.outboundRules', |
| 105 | + array_any: { |
| 106 | + path: '[*].destination', |
| 107 | + in: ['0.0.0.0/0', '::/0'], |
| 108 | + }, |
| 109 | + }, |
| 110 | + ], |
| 111 | + }, |
| 112 | + }, |
| 113 | +} |
0 commit comments