CLOUD CONCEPT

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 Concepts Hub →

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

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.

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.

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.

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.

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.

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.

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.

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.

Virtual private cloud VPC_32 image 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.

Open Amazon VPC →
AWS Firewall Manager image 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.

Open AWS Network Firewall →
Amazon Inspector image 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.

Open Amazon Inspector →