Stateful inspection, also known as dynamic packet filtering, is a firewall technology that monitors the state and context of active network connections to determine which packets should be allowed or blocked as they traverse a network. Unlike stateless (static) inspection, which examines each packet in isolation, stateful inspection tracks and records the entire lifecycle of a connection, including details such as source and destination IP addresses, port numbers, protocol types, and the sequence of packets.

How Stateful Inspection Works

• Connection Tracking: When a new connection is initiated (for example, during a TCP handshake), the firewall captures and logs relevant details in a dynamic state table.
• State Table: This table maintains information about all active connections, including their current status and metadata (e.g., IP addresses, ports, protocol flags).
• Packet Evaluation: Each incoming and outgoing packet is compared against the state table. If the packet matches an existing, legitimate connection, it is allowed through. If not, it is evaluated against firewall rules to decide whether to permit or block it.
• Context Awareness: The firewall considers both the state (such as TCP flags like SYN, ACK, FIN) and the context (source/destination, sequence numbers, etc.) to make more informed security decisions.
• Dynamic Rule Creation: For valid connections, firewalls automatically create implicit rules to allow return traffic, reducing the need for complex manual rule sets.

Key Features and Benefits

• Enhanced Security: By tracking the full context and state of connections, stateful inspection can detect and block unauthorized or suspicious traffic more effectively than stateless methods.
• Granular Control: Inspects traffic at multiple OSI layers (primarily network and transport), allowing for more refined filtering and protection against threats such as spoofing or session hijacking.
• Protocol Intelligence: Can handle both connection-oriented protocols (like TCP) and, to a limited extent, connectionless protocols (like UDP) by using timers or markers to approximate session state.
• Reduced Rule Complexity: Automatically manages connection states, simplifying firewall configuration and management.

Synonyms:
dynamic packet filtering