Cloud concept · Updated

Stateful and Stateless Filtering - Stateful and stateless filtering are approaches to permitting or blocking network packets based on either tracked connection context or independent packet-by-packet rules.

In short

Stateful filters remember permitted traffic flows and use that context to recognize return traffic, while stateless filters evaluate each packet without remembering earlier exchanges. This distinction determines how engineers configure bidirectional access, troubleshoot blocked responses, and combine workload-level controls with subnet boundaries and inspection firewalls.

Cloud Concepts Hub →

6 key aspects of Stateful and Stateless Filtering

Effective filtering depends on connection tracking, correct return-path permissions, control-specific rule semantics, and consistent enforcement across the entire traffic path.

01
Connection context versus independent packets

Stateful filters use tracked flow information to recognize permitted exchanges. Stateless filters evaluate each packet against rules without remembering whether an earlier request was allowed.

02
Return-path requirements

Stateful controls generally allow recognized return traffic for permitted flows. Stateless controls require rules for both directions, including the correct destination ephemeral ports on response packets.

03
Rule semantics are separate from statefulness

Statefulness does not inherently determine whether a filter supports explicit denies or ordered rules. For example, AWS security groups combine allow rules, while network ACLs use ordered allow and deny rules.

04
Layered enforcement

Workload-level filters, subnet controls, and routed firewalls can apply to the same traffic. Every applicable enforcement point must permit the exchange; an allow at one layer cannot override a denial elsewhere.

05
Routing and state lifecycle

Stateful inspection depends on packets reaching the enforcement point that holds the relevant flow state. Asymmetric routing, idle timeouts, and connection-table limits can interrupt traffic even when rule definitions appear correct.

06
Validation beyond an allowed request

Verify both connection initiation and response delivery using new test connections and relevant logs. A successful rule match for an outbound request does not establish that the complete exchange can succeed.

Cloud services for Stateful and Stateless Filtering

In Amazon VPC, security groups restrict access to associated network interfaces using stateful rules, while network ACLs provide stateless allow and deny controls at subnet boundaries. AWS Network Firewall adds routed inspection where traffic requires centralized filtering or deeper analysis. These controls work together only when routes deliver traffic to the intended enforcement points and every applicable layer permits the required forward and return packets. Amazon Inspector complements enforcement by identifying vulnerabilities and unintended exposure, but findings do not themselves block traffic. Troubleshooting should distinguish an assessment finding from an enforced denial and examine both directions of each affected flow.

Amazon VPCAmazon VPC

Amazon VPC provides stateful security groups for associated network interfaces and stateless network ACLs at subnet boundaries. Security groups use allow rules, while network ACLs support ordered allow and deny rules and require explicit permissions for response traffic.

AWS Network FirewallAWS Network Firewall

AWS Network Firewall provides stateless filtering followed, when configured, by stateful inspection for traffic routed through its endpoints. Stateless pass actions bypass the stateful engine, and symmetric routing is essential for reliable stateful inspection.

Amazon InspectorAmazon Inspector

Amazon Inspector identifies software vulnerabilities and unintended network exposure, helping engineers discover issues that may require network-control changes. It is an assessment service, not a stateful or stateless packet-enforcement control.

Stateful and Stateless Filtering exam questions

Real practice exam questions on Stateful and Stateless Filtering, with the correct answer and its explanation. Answer them with every option in the exam simulator.

CLF-C02

A company hosts an HTTPS application on an Amazon EC2 instance in a VPC. Only clients from the company's corporate network should be able to initiate connections to the application. The company wants response traffic to be permitted automatically, without configuring separate rules for it. All other network settings already permit the required traffic. Which traffic-filtering configuration meets these requirements?

Show answerCORRECT ANSWER

Configure a security group to allow inbound TCP port 443 from the corporate network's IP address range, with no outbound rules.

Security groups are stateful. The inbound rule permits HTTPS connections from the corporate network, and responses to those permitted connections are automatically allowed even when the security group has no outbound rules.

MLA-C02 (beta)

A company runs a self-managed ML inference service on Amazon EC2 instances in a dedicated subnet. Application instances in subnet 10.40.2.0/24 initiate TCP connections to the inference service on port 8443, using client source ports 49152–65535. The inference instances must return prediction results over these connections but must not initiate any TCP connections to the application subnet, including connections to ports 49152–65535.

The inference instances have one security group that allows inbound TCP port 8443 from the application's security group and has no outbound rules. Routing is configured correctly, and the application subnet's security controls permit the required traffic. A new network ACL for the inference subnet will deny all traffic except explicitly allowed traffic.

Which configuration meets these requirements?

Show answerCORRECT ANSWER

Keep the inference security group unchanged. Configure the inference subnet's network ACL to allow inbound TCP destination port 8443 from 10.40.2.0/24 and outbound TCP destination ports 49152–65535 to 10.40.2.0/24.

The security group automatically permits responses to allowed inbound connections, even without outbound rules. Its lack of outbound rules prevents the inference instances from initiating new TCP connections. The stateless network ACL separately permits incoming requests to port 8443 and outgoing responses to the clients' ephemeral ports.

SOA-C03

A company runs an HTTPS service on EC2 instances in a public subnet. A CloudOps engineer identifies an abusive client at IPv4 address 198.51.100.42 that has several established TCP connections to the service. These connections are tracked by the instances' security groups.

The security groups allow inbound TCP port 443 from 0.0.0.0/0 and all outbound traffic. The subnet's network ACL allows inbound TCP destination port 443 with rule 100 and outbound TCP destination ports 1024–65535 with rule 100. All other traffic is denied by the network ACL's default rules.

The engineer must block both existing and new traffic between this client and every instance in the subnet without interrupting HTTPS connections from other client IP addresses. The engineer cannot restart instances or terminate connections through the operating system.

Which change meets these requirements?

Show answerCORRECT ANSWER

Add inbound and outbound network ACL rules numbered 50 that deny all IPv4 traffic from and to 198.51.100.42/32, respectively.

Network ACLs evaluate each packet without connection tracking. These deny rules apply to both existing and new traffic. Rule 50 is evaluated before the existing allow rules numbered 100, and the /32 limits the change to the abusive client.

Practice Stateful and Stateless Filtering in a full exam

Questions on Stateful and Stateless Filtering in each practice exam, with every answer option and an explanation for each:

Start a free practice exam

What is Stateful and Stateless Filtering

3 min read

Network filtering controls which packets can cross a network boundary. Stateless filtering evaluates each packet independently using attributes such as source and destination addresses, protocol, and source and destination ports. Stateful filtering maintains a connection or flow table and considers whether a packet belongs to an existing permitted exchange. The critical difference is memory of traffic context, not simply whether a control supports allow or deny rules.

Consider a client opening an HTTPS connection from TCP port 51000 to a server on TCP port 443. A stateful filter that permits the connection can recognize the server's response to the client's port 51000 without requiring a separate rule authorizing a new connection in that direction. A stateless filter needs rules that permit the relevant packets in both directions. Allowing destination port 443 in both directions is insufficient because the response has source port 443 and destination port 51000. Production rules must accommodate the actual ephemeral port ranges used by clients and intermediaries.

Cloud platforms apply these approaches at different enforcement points. In AWS, security groups provide stateful filtering for associated network interfaces. They contain allow rules, and rules from multiple attached security groups are combined; an absent allow results in denial rather than an explicit deny rule. Return traffic for permitted flows is automatically allowed even when the opposite-direction rules would not independently allow it. This does not authorize unrelated connections initiated in the reverse direction.

VPC network access control lists, or network ACLs, provide stateless filtering at subnet boundaries. They support allow and deny rules, evaluate each direction separately, and use the first matching rule in ascending rule-number order. For an internet client reaching a web server, the subnet's ACL must permit inbound HTTPS requests and outbound responses to client ephemeral ports. A broad allow placed before a specific deny can make that deny ineffective. Security groups and network ACLs must both permit traffic where they apply; an allow in one does not override a block in the other.

AWS Network Firewall combines stateless and stateful inspection within a routed firewall deployment. Its stateless engine evaluates traffic first and can pass it, drop it, or forward it to the stateful engine. A stateless pass bypasses stateful inspection, so forwarding actions and default actions must match the inspection design. Route tables must steer the intended traffic through the firewall, and stateful inspection requires symmetric routing through the appropriate firewall endpoint so both directions share connection context.

Stateful filtering simplifies return-path rules but introduces connection-table capacity, idle-timeout behavior, and routing considerations. UDP can also be tracked using flow attributes and timeouts despite lacking TCP's connection handshake. Stateless filtering avoids connection-state maintenance, but its reverse-direction rules can require wider port ranges and cannot establish that a packet is genuinely a response merely from its header fields. Neither approach inherently provides encryption, application authentication, or full payload inspection.

When troubleshooting, trace the forward and return paths separately, checking routes, addresses after translation, ports, rule order, and every applicable control. Use VPC Flow Logs and firewall logs as evidence, recognizing that flow logs do not capture packet payloads. Test new connections after rule changes because tracked sessions may persist until their state expires. Amazon Inspector identifies software vulnerabilities and unintended network exposure; it does not enforce packet-filtering rules and cannot replace a security group, network ACL, or firewall.

Learn Stateful and Stateless Filtering in lessons

9 short lessons on Stateful and Stateless Filtering in 8 certification courses.

and 3 more lessons

Open the lessons