A New Custom Network ACL Blocks All Subnet Traffic Until Rules Allow Both Directions
Overview
The instances are running and the security groups are unchanged, yet the subnet stopped answering the moment it was associated with a new network ACL.
At a glance
- Symptom
- Soon after the subnet is moved to the new network ACL, connections to and from its instances time out.
- Likely cause
- A subnet can be associated with only one network ACL at a time, and associating a different one removes the previous association.
- Impact
- With an empty or one-sided rule set, the subnet loses inbound traffic, replies, outbound calls to databases and APIs, and load balancer health checks.
- Verification signal
- Immediately after the switch, run a request through the real path, for example the load balancer health check and one client connection from outside the subnet, and one…
- Safe correction
- Build the new network ACL fully while it is attached to nothing, then switch.
- Rollback or recovery
- Run the replace command again with the new association ID and the ID of the previous network ACL: aws ec2 replace-network-acl-association --association-id aclassoc-0newexample --network-acl-id acl-0previous.
A security review asks for a network ACL on the application subnet. Someone creates a custom one in the console, adds an inbound rule for HTTPS, associates it with the subnet and goes home. Soon after, the load balancer reports its targets unhealthy and the pager goes off, while every instance in the subnet shows as running and every security group is exactly as it was.
AWS documents the cause plainly: a new custom network ACL blocks all inbound and outbound traffic until you add rules, and network ACLs do not remember connections. The fix is to build the replacement rule set completely before the subnet touches it, then switch the association in one step that can be reversed in one step.
Symptom
Soon after the subnet is moved to the new network ACL, connections to and from its instances time out. New inbound requests may fail even though a matching inbound rule exists. Instances may still resolve names and reach the instance metadata service, which makes them look healthy from the inside.
Nothing else changed. The security groups, route tables and instances are untouched, and the previous network ACL still exists, simply no longer in use. The outage follows the association change and affects every flow through the subnet boundary.
Why the change looks safe
Two beliefs make the change feel routine. The first is that a new network ACL starts out like the default one, which AWS describes as allowing all traffic in and out. It does not: the initial rules of a custom network ACL block all inbound and outbound traffic, and the one numbered asterisk rule in each direction denies anything no other rule matches.
The second is that allowing the service port is enough, because security groups work that way. Security groups are stateful. Network ACLs are not, so permitting the request does nothing for the reply.
Root cause
A subnet can be associated with only one network ACL at a time, and associating a different one removes the previous association. From that moment the new network ACL is the only one evaluated for traffic entering and leaving the subnet. AWS also notes that rules are evaluated at the subnet boundary, not for traffic routed within the subnet.
Because network ACLs are stateless, AWS says that for every rule you add there must be an inbound or outbound rule that allows the response traffic. A reply leaves on an ephemeral port chosen by the client, so the outbound side needs a rule for that range, and a client in the subnet calling out needs the same range allowed inbound for its replies. Rules are evaluated from the lowest number up, and the first match wins.
AWS lists the ranges that clients use: many Linux kernels, including Amazon Linux, use 32768 to 61000; Windows Server 2008 and later use 49152 to 65535; requests from Elastic Load Balancing, a NAT gateway and AWS Lambda functions use 1024 to 65535. A range chosen for one client type silently drops another.
Impact
With an empty or one-sided rule set, the subnet loses inbound traffic, replies, outbound calls to databases and APIs, and load balancer health checks. The last is the visible one: AWS notes that a deny rule matching all traffic from 0.0.0.0/0 or from the subnet’s CIDR prevents load balancer health checks, and a packet that matches no allow rule reaches the asterisk deny.
AWS documents two exceptions that hide the damage: network ACLs cannot block DNS requests to the Route 53 Resolver, and cannot block traffic to the Instance Metadata Service. Instances that can still look up names and read metadata are not evidence that the network path is open.
Any later edit has the same reach. When a rule is added or deleted, every subnet associated with that network ACL is subject to the change.
How to confirm it
All of these checks are read-only. First find which network ACL the subnet uses now, with its association and entries:
aws ec2 describe-network-acls --filters Name=association.subnet-id,Values=subnet-0example1 --query 'NetworkAcls[].[NetworkAclId,Associations[].NetworkAclAssociationId,Entries[].[RuleNumber,Egress,RuleAction,Protocol,PortRange]]'
Read the entries in ascending rule number, inbound and outbound separately. A new custom network ACL shows only the asterisk deny entries, which the API reports with rule number 32767. If you see an inbound allow but no outbound rule for the reply ports, you have the one-sided case.
Then look for the rejects. If VPC Flow Logs are already enabled for the subnet or its network interfaces, the action field of a record is REJECT when security groups or network ACLs did not allow the traffic, and it does not by itself say which. Compare against the security groups to separate the two.
If flow logs are not enabled, Reachability Analyzer, which AWS describes as a static configuration analysis tool, can identify missing or misconfigured network ACL rules between two resources without sending traffic.
Why allowing everything makes it worse
Under pressure the quick repair is a rule 100 that allows all protocols from 0.0.0.0/0 inbound and outbound. Traffic returns, the page goes quiet, and the network ACL the review asked for is now a no-op that still looks like a control in the console.
It is worse than the default network ACL in one respect: it is a deliberate-looking rule that nobody will question. Only the security groups remain to filter anything, and the layer the review wanted is gone. A lower-numbered allow-all also overrides any deny placed after it, because the first matching rule applies and nothing later is read.
The related trap of a security group that references itself shows the same pattern in another layer: see A Security Group Referencing Itself Silently Opens Every Port Inside a VPC.
Correction
Build the new network ACL fully while it is attached to nothing, then switch. Do the first pass on a test subnet that carries the same traffic pattern.
- Record and back up. Save the output of the describe command above for the subnet, including its current association ID. Note which clients and services use it, and their ports. This record is the rollback.
- Create the network ACL and leave it unassociated. Use
aws ec2 create-network-acl --vpc-id vpc-0example. A new custom network ACL is not associated with a subnet by default, so nothing changes yet. Rollback: delete it. - Add allow rules for both directions of every flow. Inbound: the service port from the intended source range. Outbound: the ephemeral range for the clients that connect, for example
aws ec2 create-network-acl-entry --network-acl-id acl-0example --ingress --rule-number 100 --protocol tcp --port-range From=443,To=443 --cidr-block 10.0.0.0/16 --rule-action allowand the matching--egressrule for ports 1024 to 65535 or the narrower range for your client types. Add the opposite pair for every call the instances make out. Rule numbers run from 1 to 32766, so leave gaps of ten. Rollback:aws ec2 delete-network-acl-entry --network-acl-id acl-0example --rule-number 100 --ingress. - Review the rule set against the record. Walk each recorded flow through the inbound and outbound lists in rule order and confirm that every request has a matching reply rule. Put any deny entries at lower numbers than the broader allows they must override.
- Switch the association in one command.
aws ec2 replace-network-acl-association --association-id aclassoc-0example --network-acl-id acl-0example, using the association ID you recorded. The output gives a new association ID. Write it down, because it is what the next rollback needs.
Following along? Tap a step’s number to tick it off.
Validation
Immediately after the switch, run a request through the real path, for example the load balancer health check and one client connection from outside the subnet, and one outbound call from an instance to a dependency. Describe the subnet’s network ACL again and confirm the association and entries are the ones you built.
Watch the targets become healthy and watch for new REJECT records on the subnet’s interfaces if flow logs are on. Treat a REJECT on a port you intended to allow as a missing rule, not as noise.
Rollback
Run the replace command again with the new association ID and the ID of the previous network ACL: aws ec2 replace-network-acl-association --association-id aclassoc-0newexample --network-acl-id acl-0previous. The subnet is associated with its earlier rules again, and nothing was deleted by the switch. Keep the previous network ACL until the new one has run through a full traffic cycle, including batch jobs and health checks that only fire occasionally.
Prevention
- Create network ACLs through infrastructure as code, with the rules and the association in one reviewed change, so an empty network ACL is never attached by hand.
- Write the rules as pairs. For every inbound entry, require its reply entry in review, with the ephemeral range named for the client type.
- Associate only after a reachability check. Run Reachability Analyzer between the load balancer and an instance, and between the instance and its dependencies, before the switch.
- Keep the network ACL for coarse boundaries, such as blocking an address range, and leave per-application rules to security groups, which are stateful and cannot be mis-ordered.
Apply the safer control
Before you change production
Confirm the affected scope, export the current configuration, and test the replacement control in a non-production environment first.
Fix commands and configuration
aws ec2 describe-network-acls --filters Name=association.subnet-id,Values=subnet-0example1 --query 'NetworkAcls[].[NetworkAclId,Associations[].NetworkAclAssociationId,Entries[].[RuleNumber,Egress,RuleAction,Protocol,PortRange]]'actionREJECTWhen to escalate
Validation and rollback are covered in the sections above.
Escalate
Escalate when the blast radius is uncertain, the control cannot be tested safely, or remediation requires an outage or security exception.
Fixed? Get the next one before it hits you: The KBY Brief
Practical fixes for the systems you run, by email about twice a week. Unsubscribe at any time.
About this page
Credited to
Dates
Published
Corrections
No corrections are listed for this page. Some review sweeps corrected pages without naming each one; those are in the corrections log.
Was this useful?
Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.
Found this useful? Follow KBY for more like it.


