Welcome to Day 12 of the 30 Days AWS Security Challenge. We've covered identity, data, and secrets. Today we move into networking, starting with the two firewall-like tools AWS gives you inside a VPC: Security Groups and Network ACLs. They sound similar, and beginners often assume they do the same job, but they work in genuinely different ways.
Two Different Layers of Filtering
Security Groups and Network ACLs both control what traffic is allowed in and out, but they operate at different layers. A Security Group acts like a firewall wrapped directly around a specific resource, like an EC2 instance. A Network ACL acts like a firewall wrapped around an entire subnet, filtering traffic for everything inside it. Understanding that difference explains almost everything else about how they behave.
Security Groups: Instance Level, Stateful
A Security Group attaches directly to resources like EC2 instances, load balancers, or RDS databases. It only supports "allow" rules, there is no way to explicitly deny something with a Security Group, you simply don't add a rule allowing it.
Security Groups are also stateful, which is a detail that trips people up at first. If you allow inbound traffic on a certain port, the response traffic going back out is automatically allowed too, without needing a matching outbound rule. You only think about one direction at a time.
A typical Security Group rule might allow inbound traffic on port 443 from anywhere, so your application can serve HTTPS traffic. To configure this, go to EC2 > Security Groups > select your group > Edit inbound rules, and add an HTTPS rule with the source set to your intended range.
Network ACLs: Subnet Level, Stateless
A Network ACL sits at the subnet level, meaning it applies to every resource inside that subnet, not just one instance. Unlike Security Groups, Network ACLs support both "allow" and explicit "deny" rules, and rules are evaluated in numbered order, lowest number first, stopping at the first match.
Network ACLs are also stateless, the opposite of Security Groups. This means inbound and outbound traffic are evaluated completely independently. If you allow inbound traffic on a port, you must also explicitly allow the corresponding outbound response traffic, or connections will fail even though the inbound rule looks correct.
You can find these under VPC > Network ACLs, where each subnet is associated with exactly one ACL, though multiple subnets can share the same one.
A Side by Side Comparison
Feature | Security Group | Network ACL |
|---|
Applies to | Individual resource (EC2, RDS, etc.) | Entire subnet |
Rule types | Allow only | Allow and Deny |
State | Stateful (return traffic automatic) | Stateless (must allow both directions) |
Rule evaluation | All rules evaluated together | Evaluated in order, first match wins |
Why You Usually Use Both Together
Most real world VPC setups use Security Groups as the primary, day to day control, since they are simpler to reason about and tightly scoped to specific resources. Network ACLs are typically used as a broader, secondary layer, useful for blocking a specific known bad IP range across an entire subnet, or as an extra layer of defense in depth beyond individual instance rules.
Think of Security Groups as the lock on each individual door, and Network ACLs as a gate around the whole building. Both add protection, but they solve different problems and rarely replace each other.
A Common Mistake to Avoid
A frequent troubleshooting headache is someone adding a Network ACL deny rule to block specific traffic, then forgetting that Network ACLs are stateless. Blocking inbound traffic on a port also silently blocks the outbound response traffic tied to any legitimate connection using that port, sometimes breaking things in confusing ways. When troubleshooting connectivity issues, always check both Security Groups and Network ACLs, since either one silently blocking traffic can look identical from the application's point of view.
Key Takeaways
- Security Groups protect individual resources, Network ACLs protect entire subnets
- Security Groups only allow, Network ACLs can explicitly allow or deny
- Security Groups are stateful, Network ACLs are stateless and need rules in both directions
- Use Security Groups as your primary control, and Network ACLs as an additional layer
- When troubleshooting network issues, check both, since either can be the silent cause
Tomorrow we put these pieces together and walk through what a secure VPC actually looks like from the ground up.
Loading article