ResilientX

AWS Security Groups vs NACLs Explained

Summary:

Security groups vs NACLs in AWS: stateful vs stateless, allow vs deny, rule order, what NACLs cannot block, and a worked three-tier design that uses both.

Security groups vs NACLs comes down to where they sit and how they remember traffic. A security group is a stateful firewall attached to a resource such as an EC2 instance: it has allow rules only, evaluates all of them, and automatically lets response traffic back out. A network ACL (NACL) is a stateless filter attached to a subnet: it has allow and deny rules, evaluates them in number order, and needs explicit rules for return traffic.

In practice, security groups do most of the work and NACLs act as coarse guardrails at the subnet edge. This guide shows exactly how each behaves, what NACLs cannot block, and a worked three-tier design. It is part of our series on AWS VPC security architecture.

What is the difference between security groups and NACLs?

AWS summarizes the difference in its VPC security documentation. The table below adds the defaults and limits you meet in daily work.

CharacteristicSecurity groupNetwork ACL
Attached toA resource, such as an EC2 instance; several groups per resourceA subnet; exactly one NACL per subnet
Rule typesAllow onlyAllow and deny
EvaluationAll rules are evaluated before a decisionRules evaluated in ascending number order; first match wins
Return trafficAllowed automatically (stateful)Must be allowed explicitly (stateless)
New or default stateNew group: no inbound rules, all outbound allowedEvery NACL ends with an asterisk rule that denies anything unmatched
Can referenceOther security groups as source or destinationIP ranges only
Typical usePrimary, fine-grained control per workloadSubnet guardrails and quick blocks of specific ranges

How do security group rules work?

A security group only allows. According to AWS, "You can specify allow rules, but not deny rules." Anything not allowed is dropped.

Three behaviors matter most:

  • Stateful. If a request is allowed in, the response is allowed out, whatever the outbound rules say.
  • Defaults. A new security group has no inbound rules, so nothing reaches the resource until you add one. It has one outbound rule that allows all outbound traffic.
  • Group references. A rule can name another security group as its source or destination. A database group can then allow traffic "from the app tier group" instead of from IP addresses, and new app instances inherit access automatically.

Changes apply immediately to every resource that uses the group. A resource can carry several groups, and the effective permission is the union of their rules.

How do NACL rules work?

A network ACL filters traffic at the subnet boundary. Every subnet must be associated with one; if you do not choose, the subnet uses the VPC's default NACL. A subnet can only have one NACL at a time, though one NACL can serve many subnets.

Rules are numbered from 1 to 32766. AWS evaluates them starting with the lowest number, applies the first match and stops. At the end sits an asterisk rule that denies any packet nothing else matched, and it cannot be deleted. AWS recommends numbering in increments of 10 or 100 so you can insert rules later.

Because NACLs are stateless, allowing a request in does not allow its response out. Every NACL that restricts traffic needs matching rules for the return path, which for client connections means the ephemeral port range your clients and services use.

What can't a NACL block?

This is the part most comparisons leave out. AWS states that network ACLs do not filter traffic to and from:

  • Amazon DNS, including the Route 53 Resolver
  • Amazon DHCP
  • The EC2 instance metadata service (IMDS)
  • Amazon ECS task metadata endpoints
  • License activation for Windows instances
  • Amazon Time Sync Service
  • Reserved IP addresses used by the default VPC router

The practical consequence: a NACL cannot stop an instance from querying its metadata service or resolving names through Amazon DNS. Controls for those paths live elsewhere, such as IMDSv2 settings on the instance, covered in our EC2 instance hardening guide, and DNS-layer filtering.

A worked example: a three-tier web app

Here is a design that uses both controls for what they do best.

LayerSecurity group rulesNACL on the subnet
Load balancer (public subnets)Inbound 443 from the internetAllow inbound 443; allow return traffic on ephemeral ports; deny known-bad ranges with low rule numbers
Application (private subnets)Inbound app port from the load balancer's security group onlyAllow traffic from the public subnets' range and the return path; deny everything else
Database (private subnets)Inbound database port from the application security group onlyAllow the database port from the app subnets' range only; deny the rest

Notice where the precision lives. The security groups reference each other, so the database accepts connections only from instances in the app group, wherever they run. The NACLs only express coarse subnet-to-subnet intent. If someone launches an instance in the database subnet with a permissive security group, the NACL still keeps internet traffic out, which is the defense-in-depth case AWS describes.

When should you use NACLs at all?

AWS is explicit: "You can secure your instances using only security groups. However, you can add network ACLs as an additional layer of defense." Use them when one of these applies:

  • You need to deny a specific range quickly, which security groups cannot do
  • You want subnet guardrails that hold even if a security group is misconfigured
  • A compliance requirement calls for segmentation at the network layer between subnets

Keep NACL rule sets short. A long NACL is hard to reason about, and a single wrong rule number can silently shadow every rule after it.

What are the most common mistakes?

  • 0.0.0.0/0 on SSH or RDP in a security group. Use Systems Manager or a bastion with a narrow source instead.
  • Forgetting return traffic in a NACL, which breaks connections in ways that look like application bugs.
  • A broad allow numbered before a narrow deny, so the deny never fires.
  • Treating the NACL as the primary control and leaving security groups wide open.
  • Workloads left in the default security group, which mixes unrelated resources.
  • Unused security groups that still allow traffic and get attached by mistake later.

These are exactly the misconfigurations that drift back in after a clean audit, which is why checking them once is not enough.

How do you keep them audited?

Review rules on a schedule, and monitor between reviews. ResilientX cloud security posture monitoring connects to AWS, Azure and GCP agentlessly through their APIs, scans resources across regions, and flags open ports, misconfigured firewalls, risky IAM policies and public storage, with CIS AWS Foundations benchmark scoring. Pair it with external attack surface management to confirm what is actually reachable from the internet. Assess your cloud security posture with ResilientX UEM before the next change window.

Frequently asked questions

Do I need both security groups and NACLs?

You always have both, because every subnet has a NACL. The question is whether to customize it. Most workloads are well protected by tight security groups and the default NACL. Customize NACLs when you need explicit denies, subnet guardrails or network-layer segmentation, and keep their rules few and well documented.

Which is evaluated first, the NACL or the security group?

For traffic entering an instance from outside its subnet, the subnet's NACL filters the packet at the subnet boundary before the instance's security group sees it. Outbound, the security group applies at the instance first and the NACL at the subnet edge after. Both must allow the traffic for it to pass.

Can a NACL block the instance metadata service?

No. AWS documents that network ACLs cannot block traffic to the instance metadata service, Amazon DNS and a few other link-local services. Protect metadata on the instance itself, for example by requiring IMDSv2 and limiting the hop count, and use IAM to limit what the instance role can do.

The short version

Use security groups as your primary, fine-grained control and reference groups instead of IP addresses where you can. Add NACLs for denies and subnet guardrails, keep them short, and remember they are stateless and cannot touch metadata or Amazon DNS. Then monitor both, because rules drift.

Assess your cloud security posture with ResilientX UEM — book a demo and see your security groups and NACLs checked across every account and region.

One platform for your entire exposure
Explore Unified Exposure Management →