More Info:
Ensuring that the Amazon VPC route table associated with the data-tier subnets has no default route configured to allow access to an AWS NAT Gateway in order to restrict Internet connectivity for the EC2 instances available within the data tier.Risk Level
MediumAddress
SecurityCompliance Standards
- APRA CPS 234 (Australia)
- BSI C5 (Germany)
- Brazil LGPD
- CCPA / CPRA (California)
- CIS Critical Security Controls v8
- CMMC 2.0
- CSA Cloud Controls Matrix v4
- DPDPA
- Digital Operational Resilience Act (EU)
- Essential 8
- GDPR
- ISO/IEC 27017
- ISO/IEC 27018
- ISO/IEC 27701
- KSA PDPL
- MAS Technology Risk Management (Singapore)
- MITRE ATT&CK (Cloud)
- NIST SP 800-171
- NYDFS 23 NYCRR 500
- SWIFT Customer Security Controls Framework
- Sarbanes-Oxley IT General Controls
- UK NCSC Cyber Assessment Framework
Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
To remediate the misconfiguration of restricting data-tier subnet connectivity to VPC NAT Gateway in AWS, please follow these step-by-step instructions:
- Go to the AWS Management Console and navigate to the VPC service.
- Select the VPC in which your data-tier subnet resides.
- Click on the “Subnets” option in the left-hand menu.
- Select the data-tier subnet that needs to be remediated.
- Click on the “Route Table” tab in the bottom pane.
- Click the “Edit” button to edit the route table.
- Remove any routes that allow traffic to flow directly from the data-tier subnet to the internet or any other destination.
- Add a new route to the route table that directs all traffic from the data-tier subnet to the NAT Gateway.
- Save the changes to the route table.
- Verify that the data-tier subnet is now only able to communicate with the internet or other destinations via the NAT Gateway.
- Repeat these steps for any other data-tier subnets in the VPC that need to be remediated.
Using CLI
Using CLI
To remediate the misconfiguration “Restrict data-tier subnet connectivity to VPC NAT Gateway” in AWS using the AWS CLI, follow the steps below:Replace Replace Replace Replace Replace
- Open the AWS CLI and run the following command to get the ID of the VPC that contains the data-tier subnet:
- Run the following command to get the ID of the NAT Gateway:
<VPC_ID> with the ID of the VPC obtained in step 1.- Run the following command to create a new security group that allows inbound traffic only from the NAT Gateway:
<VPC_ID> with the ID of the VPC obtained in step 1.- Run the following command to authorize inbound traffic from the NAT Gateway to the new security group:
<SG_ID> with the ID of the new security group created in step 3 and <NAT_SG_ID> with the security group ID of the NAT Gateway obtained in step 2.- Run the following command to modify the network ACL of the data-tier subnet to allow inbound traffic only from the new security group:
<ASSOC_ID> with the ID of the network ACL association for the data-tier subnet and <ACL_ID> with the ID of the network ACL for the data-tier subnet.- Run the following command to add an inbound rule to the network ACL that allows inbound traffic only from the new security group:
<ACL_ID> with the ID of the network ACL for the data-tier subnet.- Verify that the misconfiguration has been remediated by testing connectivity to the data-tier subnet from a resource outside the VPC.
Using Python
Using Python
To remediate the misconfiguration of restricting data-tier subnet connectivity to VPC NAT Gateway in AWS using Python, you can follow these steps:Note: You will need to have appropriate AWS credentials set up to run this code. Also, make sure to replace the VPC ID and subnet ID with your own values.
- Open the AWS console and navigate to the VPC service.
- Select the VPC that contains the data-tier subnet.
- Click on the “Subnets” tab and select the data-tier subnet.
- Click on the “Route Table” tab and note the route table associated with the data-tier subnet.
- Navigate to the “Route Tables” section and select the route table noted in step 4.
- Click on the “Routes” tab and locate the route that allows traffic to the internet gateway.
- Edit the route and change the target to the NAT gateway associated with the VPC.
- Save the changes.
Using Terraform
Using Terraform
aws_route resource (or route {} block) that defines cidr_block = "0.0.0.0/0" pointing to a NAT Gateway for this route table (for example, nat_gateway_id = aws_nat_gateway.NAT_GATEWAY.id). This change is destructive and will remove Internet connectivity via the NAT Gateway for all resources in the data-tier subnet, but it does not normally force replacement of the route table itself—Terraform will show the default route being destroyed.For verification, terraform plan should show the aws_route (or inline route) with cidr_block = "0.0.0.0/0" and nat_gateway_id = ... being removed, with no new default route to a NAT Gateway created.
