# 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.

Cloud concept. Updated 2026-10-29. Page: https://blowstack.com/tools/cloud-concepts-hub/stateful-and-stateless-filtering

> 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.

Practice exams covering Stateful and Stateless Filtering: [ANS-C01 AWS Certified Advanced Networking - Specialty](https://blowstack.com/practice-exams/aws-certified-advanced-networking-specialty), [CLF-C02 AWS Certified Cloud Practitioner](https://blowstack.com/practice-exams/aws-certified-cloud-practitioner), [SOA-C03 AWS Certified CloudOps Engineer - Associate](https://blowstack.com/practice-exams/aws-certified-cloudops-engineer-associate), [DEA-C01 AWS Certified Data Engineer - Associate](https://blowstack.com/practice-exams/aws-certified-data-engineer-associate), [DOP-C02 AWS Certified DevOps Engineer - Professional](https://blowstack.com/practice-exams/aws-certified-devops-engineer-professional), [MLA-C02 (beta) AWS Certified Machine Learning Engineer - Associate](https://blowstack.com/practice-exams/aws-certified-machine-learning-engineer-associate), [SCS-C03 AWS Certified Security - Specialty](https://blowstack.com/practice-exams/aws-certified-security-specialty), [SAA-C03 AWS Certified Solutions Architect - Associate](https://blowstack.com/practice-exams/aws-certified-solutions-architect-associate), [SAP-C03 AWS Certified Solutions Architect - Professional](https://blowstack.com/practice-exams/aws-certified-solutions-architect-professional).

## 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.

1. **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.
2. **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.
3. **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.
4. **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.
5. **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.
6. **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 VPC](https://blowstack.com/tools/cloud-services-hub/amazon-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 Firewall](https://blowstack.com/tools/cloud-services-hub/aws-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 Inspector](https://blowstack.com/tools/cloud-services-hub/amazon-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.

### Question 1 (CLF-C02)

**Question:**

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?

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

**Explanation:** 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.

### Question 2 (MLA-C02 (beta))

**Question:**

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?

**Correct 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.

**Explanation:** 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.

### Question 3 (SOA-C03)

**Question:**

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?

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

**Explanation:** 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.

### Question 4 (SCS-C03)

**Question:**

A company uses AWS Network Firewall to inspect connections from EC2 application instances in 10.20.10.0/24 to an on-premises service in 172.20.50.0/24. The service uses an unencrypted application protocol on TCP port 8443. Application clients use TCP source ports 49152–65535. Both directions traverse the same firewall endpoint, and no address translation occurs. Security groups, network ACLs, and routing permit the required traffic.

The firewall has one stateless rule:
• Source: 10.20.10.0/24, TCP ports 49152–65535
• Destination: 172.20.50.0/24, TCP port 8443
• Action: aws:forward_to_sfe

The stateless default action is aws:drop. The stateful configuration has been validated to permit the application sessions while blocking prohibited payload signatures when both directions reach the stateful engine.

Connections time out. Packet captures show that the service receives TCP SYN packets and sends SYN-ACK packets. Firewall logs show that the SYN-ACK packets are dropped during stateless processing. All tested packets are unfragmented.

Which change will restore connectivity while ensuring that both directions of each permitted connection undergo stateful inspection?

**Correct answer:** Add a stateless rule with action aws:forward_to_sfe for TCP traffic from 172.20.50.0/24, source port 8443, to 10.20.10.0/24, destination ports 49152–65535.

**Explanation:** Stateless processing evaluates each packet independently, including responses to connections already known to the stateful engine. This reverse-direction rule matches the SYN-ACK packets and forwards them to the stateful engine, where they can be associated with the application sessions and inspected.

### Question 5 (DEA-C01)

**Question:**

A data ingestion service runs on an Amazon EC2 instance. An on-premises appliance at 10.60.4.20 uploads batches to the service over TCP port 443. After validating each batch, the service must initiate a separate TCP connection to port 9443 on the appliance to deliver a validation report. Both systems use ephemeral source ports in the range 32768–60999.

The EC2 instance's only security group allows inbound TCP port 443 from 10.60.4.20/32 and has no outbound rules. Uploads and their HTTP responses succeed, but the service cannot establish the separate report-delivery connections. Routing, the appliance's firewall, and the stateless network ACLs permit both exchanges in both directions.

Which security group update will allow report delivery without authorizing unnecessary traffic?

**Correct answer:** Add an outbound rule allowing TCP destination port 9443 to 10.60.4.20/32.

**Explanation:** Security groups automatically permit responses within an allowed connection, which explains why upload responses succeed without outbound rules. The report delivery is a separate, EC2-initiated connection and therefore needs an outbound allow rule for the appliance's destination port 9443. Its return traffic is automatically allowed. The network ACLs already permit the necessary packets in both directions.

### Question 6 (DOP-C02)

**Question:**

A company uses an infrastructure-as-code pipeline to deploy ephemeral EC2 build workers and an internal artifact server into separate private subnets in the same VPC. Workers initiate TCP connections to the server on port 8443. The worker operating system is configured to use TCP source ports 40000–49999 for these connections. Traffic travels directly between the subnets without a proxy or address translation, and routing is correct.

The worker security group allows outbound TCP port 8443 to the server security group and has no inbound rules. The server security group allows inbound TCP port 8443 from the worker security group and has no outbound rules. No other security groups are attached.

A security-hardening deployment replaces permissive network ACLs with these custom ACLs:

• Worker subnet: Allow outbound TCP destination port 8443 to the server subnet CIDR; deny all other traffic.
• Server subnet: Allow inbound TCP destination port 8443 from the worker subnet CIDR; deny all other traffic.

Artifact downloads now time out. The company must restore downloads without allowing the server to initiate new connections to workers. All added network ACL rules will be evaluated before the default deny rules.

Which change should a DevOps engineer make to the infrastructure-as-code templates?

**Correct answer:** Add an outbound network ACL allow rule on the server subnet for TCP destination ports 40000–49999 to the worker subnet CIDR. Add an inbound network ACL allow rule on the worker subnet for the same destination port range from the server subnet CIDR. Leave both security groups unchanged.

**Explanation:** Network ACLs evaluate each packet independently. Responses have source port 8443 and destination ports in the workers' configured ephemeral range, so both the server subnet's outbound ACL and the worker subnet's inbound ACL must allow that range. Security groups recognize return traffic for permitted connections even without opposite-direction rules. Leaving the security groups unchanged continues to block new server-initiated connections to workers.

### Question 7 (SAA-C03)

**Question:**

A company runs a job coordinator and a fleet of processing workers on Amazon EC2 instances in separate subnets of the same VPC. The coordinator initiates TCP connections to the workers on port 8443 to assign jobs. After completing a job, each worker initiates a separate TCP connection to the coordinator on port 9443 to upload results. Both applications use ephemeral source ports 32768–60999.

The coordinator's security group allows outbound TCP port 8443 to the workers' security group and has no inbound rules. The workers' security group allows inbound TCP port 8443 from the coordinator's security group and outbound TCP port 9443 to the coordinator's security group. These are the only attached security groups. Network ACLs allow all traffic, and routing is correct.

Job assignment succeeds, but result uploads time out. Which change will allow result uploads while maintaining least-privilege access?

**Correct answer:** Add an inbound rule to the coordinator's security group allowing TCP port 9443 from the workers' security group.

**Explanation:** Each result upload is a new connection initiated by a worker, not return traffic for the coordinator's job-assignment connection. The coordinator therefore needs an inbound rule for destination port 9443. Referencing the workers' security group restricts access to the worker fleet. Responses to permitted uploads are automatically allowed without an additional outbound rule.

### Question 8 (ANS-C01)

**Question:**

During a network containment audit, a company tests whether it can immediately stop HTTPS communication from EC2 instances in a dedicated subnet to a compromised external IPv4 address. An instance has an established TCP connection from local port 55000 to port 443 on that address. The connection is tracked by its security group.

The security group permits outbound TCP port 443 to the external address and has no inbound rules. The subnet's network ACL has rule 100 allowing all IPv4 traffic in each direction, followed by the default deny. No other security groups are attached.

The audit requires a control that stops both existing and newly initiated HTTPS connections to the compromised address without interrupting traffic to other external addresses. The validation must demonstrate containment of the existing connection, not merely failure of a new connection attempt.

Which action meets these requirements?

**Correct answer:** Add network ACL rule 50 in each direction to deny all TCP traffic to or from the compromised address's /32 CIDR. Validate that the existing connection stops transferring application data and that new HTTPS connections fail.

**Explanation:** Network ACLs evaluate packets independently of security group connection state. Inbound and outbound denies for the specific /32, evaluated before rule 100, block packets belonging to both existing and new connections. Other external addresses remain unaffected. Testing the established session and a new connection provides evidence of both containment requirements.

## 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:

- [ANS-C01](https://blowstack.com/practice-exams/aws-certified-advanced-networking-specialty): 12 questions
- [SAA-C03](https://blowstack.com/practice-exams/aws-certified-solutions-architect-associate): 7 questions
- [SOA-C03](https://blowstack.com/practice-exams/aws-certified-cloudops-engineer-associate): 6 questions
- [SCS-C03](https://blowstack.com/practice-exams/aws-certified-security-specialty): 5 questions
- [DEA-C01](https://blowstack.com/practice-exams/aws-certified-data-engineer-associate): 5 questions
- [MLA-C02 (beta)](https://blowstack.com/practice-exams/aws-certified-machine-learning-engineer-associate): 3 questions
- [DOP-C02](https://blowstack.com/practice-exams/aws-certified-devops-engineer-professional): 3 questions
- [CLF-C02](https://blowstack.com/practice-exams/aws-certified-cloud-practitioner): 2 questions
- [SAP-C03](https://blowstack.com/practice-exams/aws-certified-solutions-architect-professional): 1 question

## What is Stateful and Stateless Filtering

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.

- CLF-C02: Stateful and Stateless Filtering: connection memory and return traffic (Premium), https://app.blowstack.com/lessons/stateful-and-stateless-filtering-connection-memory-and-return-traffic-clf-c02
- MLA-C02 (beta): Stateful and Stateless Filtering: request and return traffic (Premium), https://app.blowstack.com/lessons/stateful-and-stateless-filtering-request-and-return-traffic-mla-c02
- SAP-C03: Deep Packet Inspection vs. Stateful and Stateless Filtering (Premium), https://app.blowstack.com/lessons/deep-packet-inspection-vs-stateful-and-stateless-filtering-sap-c03
- SOA-C03: Stateful and Stateless Filtering: configuring request and return traffic (Premium), https://app.blowstack.com/lessons/stateful-and-stateless-filtering-configuring-request-and-return-traffic-soa-c03
- SCS-C03: Stateful and Stateless Filtering: bidirectional traffic authorization (Premium), https://app.blowstack.com/lessons/stateful-and-stateless-filtering-bidirectional-traffic-authorization-scs-c03
- DEA-C01: Stateful and Stateless Filtering: security group flow tracking (free), https://app.blowstack.com/lessons/stateful-and-stateless-filtering-security-group-flow-tracking-dea-c01
