Securing Networks ยท 3.4

๐Ÿงฑ Network-Based Firewalls

The gatekeepers that enforce access control between networksโฑ ~2 min

๐Ÿ›‚A firewall is a border checkpoint for network traffic

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 TypeOSI LayerWhat It ExaminesStrengthWeakness
Packet FilteringLayer 3-4Source/dest IP, port, protocol โ€” nothing elseFast; low overhead; transparentNo state awareness; can't detect fragmented or spoofed attacks; easily bypassed
Stateful InspectionLayer 3-4Full connection state; tracks TCP handshakes; validates packets are part of established sessionsBlocks unsolicited packets; detects some attack patterns; much harder to spoofStill no application-layer visibility
Application-Layer (Proxy)Layer 7Full payload content; understands specific protocols (HTTP, FTP, DNS)Deeply inspects content; can detect malicious payloads, not just headersHigh latency; must proxy every connection; one proxy per application type
Next-Generation Firewall (NGFW)Layers 3-7All of the above plus: application ID, user identity, SSL inspection, IPS, threat intelMost comprehensive; single device for multiple functionsMost expensive; requires tuning; SSL inspection has privacy implications

Packet Filtering vs. Stateful โ€” The Key Difference

Packet Filter (stateless)
  • โ€ข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
Stateful Inspection
  • โ€ข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
๐Ÿ”’ SecurityThe principle of least privilege applied to firewalls: default-deny. A properly configured firewall denies all traffic by default and only permits explicitly required connections. The reverse (default-allow, block known bad) is far less effective โ€” you can't enumerate all bad traffic, but you can enumerate all legitimate traffic.
๐Ÿง Quick Checkfirst try = +5 XP

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?

โญ 0 XP๐Ÿ”ฅ 0 days