Course contentsShow
← Security
Lesson 418 of 3,05210. Network Security - Firewalls and SegmentationFree lesson

Stateful Inspection Firewalls

Understand connection tracking and how stateful firewalls maintain session state for better security.

Stateful Inspection Firewalls

What you'll learn: How stateful firewalls track active connections to make smarter security decisions than simple packet filters.

The Evolution Beyond Packet Filtering

Remember packet filtering firewalls from the previous lesson? They examine each packet individually, checking basic headers like source/destination IP and port. While useful, they have a critical weakness: they can't tell if a packet is part of a legitimate conversation or a cleverly crafted attack.

Stateful inspection firewalls solve this by maintaining a "memory" of active network connections. They track the entire lifecycle of communications—from the initial handshake to the final termination.

How Connection Tracking Works

Think of a stateful firewall like a hotel security guard with a logbook. When a guest (connection) arrives and checks in (TCP handshake begins), the guard writes down their name, room number, and expected checkout time. The guard then recognizes this guest during their stay and allows them to come and go freely. When they check out, the entry is removed from the logbook.

The firewall maintains a state table that tracks:

  • Source and destination IP addresses and ports
  • Connection state (establishing, established, closing)
  • Sequence numbers (for TCP)
  • Timeout values

When a packet arrives, the firewall checks: "Is this packet part of a conversation I already know about?" If yes and the packet fits the expected pattern, it's allowed. If it's trying to join mid-conversation without a proper handshake, it's blocked.

Security Advantages

This approach stops many attacks that fool packet filters, including:

  • TCP ACK scans that send acknowledgments without establishing connections
  • Session hijacking attempts with invalid sequence numbers
  • Packets claiming to be responses when no request was made

Key Takeaway: Stateful firewalls track connection context (state) over time, allowing them to distinguish legitimate traffic from spoofed or malicious packets trying to bypass simple rule checks.