๐งฑ Network-Based Firewalls
The gatekeepers that enforce access control between networksโฑ ~2 min
At an international border, customs agents check who is entering and what they're carrying, applying rules to allow, deny, or inspect travelers. A network firewall does the same for packets: checking source, destination, protocol, and port against a ruleset, then allowing or blocking accordingly. A network-based firewall sits inline between network segments and enforces policy for all traffic flowing between them โ not just one device.
Four Types of Network-Based Firewalls
| Firewall Type | OSI Layer | What It Examines | Strength | Weakness |
|---|---|---|---|---|
| Packet Filtering | Layer 3-4 | Source/dest IP, port, protocol โ nothing else | Fast; low overhead; transparent | No state awareness; can't detect fragmented or spoofed attacks; easily bypassed |
| Stateful Inspection | Layer 3-4 | Full connection state; tracks TCP handshakes; validates packets are part of established sessions | Blocks unsolicited packets; detects some attack patterns; much harder to spoof | Still no application-layer visibility |
| Application-Layer (Proxy) | Layer 7 | Full payload content; understands specific protocols (HTTP, FTP, DNS) | Deeply inspects content; can detect malicious payloads, not just headers | High latency; must proxy every connection; one proxy per application type |
| Next-Generation Firewall (NGFW) | Layers 3-7 | All of the above plus: application ID, user identity, SSL inspection, IPS, threat intel | Most comprehensive; single device for multiple functions | Most expensive; requires tuning; SSL inspection has privacy implications |
Packet Filtering vs. Stateful โ The Key Difference
- โขRule: Allow TCP port 80 inbound
- โขAttacker sends ACK packet with no SYN first
- โขFirewall sees: TCP port 80 โ โ ALLOWS IT
- โขProblem: no legitimate connection was established
- โขAttacker exploits this to bypass the firewall
- โขDoes not track whether connections are valid
- โขRule: Allow TCP port 80 inbound
- โขAttacker sends ACK packet with no SYN first
- โขFirewall checks state table: no SYN recorded
- โขThis ACK has no matching connection โ BLOCK
- โขOnly packets matching established sessions pass
- โขTracks full 3-way handshake and connection lifecycle
Firewall Benefits and Limitations
- โขโ Prevents unauthorized access โ enforces access control policy at network boundaries
- โขโ Sanitizes protocol flow โ application-aware firewalls detect protocol abuse
- โขโ Reduces attack surface โ hides internal topology; blocks unsolicited inbound connections
- โขโ Logs and audits โ creates record of allowed/denied traffic for forensic analysis
- โขโ Cannot inspect encrypted traffic by default โ attacker inside TLS tunnel bypasses inspection (NGFW can decrypt/re-encrypt)
- โขโ Not effective against insider threats โ authorized internal users are trusted by policy
- โขโ Cannot stop application-layer attacks through allowed ports โ SQL injection over port 443 bypasses packet/stateful filters
- โขโ Misconfiguration is common โ 'allow any any' rules or overly permissive policies defeat the purpose
A company's stateful firewall allows outbound HTTP (port 80) and HTTPS (port 443) connections. A piece of malware on an internal computer communicates with its command-and-control server by sending commands disguised as normal HTTPS web traffic on port 443. The firewall sees valid HTTPS connections going to what appears to be a web server. Does the stateful firewall block this?