4.3.29 · D3Computer Networks

Worked examples — Firewalls — stateless vs stateful packet filtering

3,286 words15 min readBack to topic

Before we begin, three plain-word reminders (we will not use a term before this):

We reuse the parent's tiny ruleset throughout:

# Dir Proto Src Dst Dst Port Flag Action
1 out TCP 10.0.0.0/24 any 80,443 ALLOW
2 in TCP any 10.0.0.0/24 >1023 ACK=1 ALLOW
3 * * any any any DENY

Our internal network is 10.0.0.0/24 (addresses 10.0.0.010.0.0.255).


The scenario matrix

Every packet a filter sees falls into one of these cells. The two axes that matter are direction (out / in) and what the flags + state say. We also fold in the degenerate inputs (empty table, port on the boundary) and limiting behaviour (table full).

Cell Direction Flag pattern Legit? Stateless verdict Stateful verdict Covered by
A out SYN (ACK=0) new conn ALLOW (rule 1) ALLOW + create entry Ex 1
B in SYN-ACK, is a real reply ALLOW (rule 2, ACK=1) ALLOW via table Ex 2
C in ACK=1, no real conn (spoof) ALLOW (leak!) DROP (not in table) Ex 3
D in SYN (ACK=0), new inbound conn DROP (rule 2 needs ACK=1) DROP Ex 4
E in dst port = 1023 vs 1024 (boundary) rule 2 edge test same Ex 5
F in data on ESTABLISHED conn ALLOW (ACK=1) ALLOW (fast path) Ex 6
G close FIN vs RST tears down ALLOW (if ACK=1) ALLOW + delete entry Ex 7
H in flood of SYNs, table full (limiting) shrugs (no table) table exhaustion DoS Ex 8
I in active-FTP 2nd channel (word problem) needs huge port hole ALG opens 1 port Ex 9
J in UDP DNS reply (no flags!) (exam twist) rule 2 fails (no ACK) ALLOW via pseudo-state Ex 10

We now work one example per cell. Directions and states are drawn in the figures — look at the arrows, not just the words.

Figure — Firewalls — stateless vs stateful packet filtering

Worked examples


Recall Cover check — one line per cell

Cell C: stateless verdict on a forged ACK=1 packet? ::: ALLOW (the leak) — stateful DROPs it. Cell E: does dst port 1023 pass rule 2's >1023 test? ::: No — strictly greater, so DENY. Cell G: how does RST teardown differ from FIN? ::: RST closes immediately (no handshake, may have ACK=0); FIN is a negotiated close. Cell H: which firewall does a SYN flood exhaust? ::: The stateful one (its table fills); stateless shrugs. Cell J: why does rule 2 fail for a UDP DNS reply? ::: UDP has no ACK flag (and isn't TCP), so the ACK trick can't match.