0Pricing
AWS Security Academy · Lesson

Stateful versus Stateless Behavior

Grasp why return traffic is handled differently by each control.

Stateful versus Stateless Behavior is a free AWS Security Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AWS Security Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Two Models

The deepest difference between security groups and network ACLs is state tracking. Security groups are stateful; network ACLs are stateless. This single property changes how you write rules, troubleshoot dropped traffic, and reason about return packets.

What Stateful Means

Stateful means the firewall remembers each connection it permits. When a security group allows an inbound request, it automatically allows the matching response back out, tracking the connection in a state table. You never write a rule for return traffic.

What Stateless Means

Stateless means the firewall evaluates every packet independently with no memory of prior packets. A network ACL that allows an inbound request does not automatically allow the response. You must add a separate rule for the return direction, or the reply is dropped.

Why It Matters for Return Traffic

A client connects to your web server on port 443. The server replies from port 443 to the client on a high ephemeral port. With a security group, this reply is automatic. With a NACL, you need an outbound allow for the ephemeral range, or the connection appears to hang and then fails.

The Ephemeral Port Trap

Forgetting ephemeral ports in NACL outbound rules is the most common stateless mistake. The request reaches the server but the response is silently rejected. Always allow the relevant ephemeral range (commonly 1024–65535) for outbound replies in custom NACLs.

# Outbound NACL allow for return traffic
Rule 100: TCP 1024-65535 to 0.0.0.0/0  ALLOW

Troubleshooting Differences

When traffic is mysteriously blocked, check the layer that matches the symptom. If a connection establishes but replies fail, suspect a stateless NACL missing ephemeral ports. If nothing connects at all, suspect a missing security group allow or a NACL deny on the request port.

Evaluation Order

For inbound traffic to a resource, the NACL is evaluated first at the subnet edge, then the security group at the ENI. For outbound, the security group is checked first, then the NACL. Both must permit the traffic for it to pass, so either layer can silently block a flow.

Performance and Simplicity

Statefulness makes security groups simpler to manage and is why they are the everyday tool. You describe intent once and return traffic just works. Stateless NACLs require double the rules and careful port math, which is why they are used selectively.

When Stateless Helps

Statelessness is occasionally an advantage. Because NACLs treat each packet alone, a deny rule blocks traffic in one direction without affecting the other and applies to all connections instantly, including established ones. This makes NACLs effective for hard, immediate blocks during incidents.

Established Connections

Changing a security group rule affects existing tracked connections for new packets, but state tracking can keep some flows alive briefly. A NACL deny, being stateless, takes effect on the very next packet of any connection. This immediacy matters when containing an active attacker.

Summary Mental Model

Think of the security group as a smart bouncer who remembers who he let in and waves them back out, and the NACL as a rule sheet checked per packet with no memory. Knowing which is stateful is one of the most tested facts on the SCS-C02 exam.

Quick Check

Apply the stateful versus stateless distinction.

Recap

Security groups are stateful: permitted requests get automatic return traffic. Network ACLs are stateless: every packet is judged alone, so you must explicitly allow ephemeral ports for replies. Inbound order is NACL then SG; outbound is SG then NACL, and both must permit. Connections that establish but whose replies fail signal a stateless ephemeral-port gap.

Frequently asked questions

Is the “Stateful versus Stateless Behavior” lesson free?

Yes — the full text of “Stateful versus Stateless Behavior” is free to read here on the web, and the AWS Security Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AWS Security Academy course, upgrade to CoddyKit PRO.

What will I learn in “Stateful versus Stateless Behavior”?

Grasp why return traffic is handled differently by each control. You practise AWS Security Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start AWS Security Academy?

No prior experience is required. AWS Security Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Stateful versus Stateless Behavior” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this AWS Security Academy lesson?

Yes. Every AWS Security Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. How Security Groups Filter Traffic
  2. How Network ACLs Filter Subnets
  3. Stateful versus Stateless Behavior
  4. Layering Both for Defense in Depth
← Back to AWS Security Academy