|
| 1 | +# Security Model: Port Restrictions vs Domain Allowlist |
| 2 | + |
| 3 | +## TL;DR |
| 4 | + |
| 5 | +**Domain allowlist is the primary security control. Port restrictions are defense-in-depth.** |
| 6 | + |
| 7 | +## Why Squid Restricts CONNECT to Ports 80/443 |
| 8 | + |
| 9 | +The HTTP `CONNECT` method creates a blind TCP tunnel. From [Squid's official documentation](https://wiki.squid-cache.org/Features/HTTPS): |
| 10 | + |
| 11 | +> "It is important to notice that the protocols passed through CONNECT are not limited to the ones Squid normally handles. Quite literally **anything that uses a two-way TCP connection** can be passed through a CONNECT tunnel." |
| 12 | +
|
| 13 | +This is why Squid's default ACL starts with `deny CONNECT !SSL_Ports`. |
| 14 | + |
| 15 | +## The Case Against Port Restrictions (Counter-Arguments) |
| 16 | + |
| 17 | +**Industry consensus: Port-based filtering is increasingly obsolete.** |
| 18 | + |
| 19 | +From [Palo Alto Networks](https://www.paloaltonetworks.co.uk/cyberpedia/what-is-a-next-generation-firewall-ngfw): "Developers began tunneling application traffic through common ports like 80 and 443 to bypass restrictive firewalls. This rendered port-based filtering largely ineffective." |
| 20 | + |
| 21 | +Bypass techniques are well-documented: |
| 22 | +- **SSH over 443**: Run `sshd -p 443`, tunnel anything ([documented extensively](https://blog.frost.kiwi/ssh-over-https-tunneling/)) |
| 23 | +- **SSLH multiplexing**: Same port serves SSH and HTTPS based on protocol detection |
| 24 | +- **HTTP tunneling tools**: chisel, wstunnel, cloudflared work over "allowed" ports |
| 25 | + |
| 26 | +Even [Nmap's documentation](https://nmap.org/book/firewall-subversion.html) notes historical firewall flaws—Zone Alarm allowed any UDP from port 53, Windows IPsec filters allowed all traffic from port 88. |
| 27 | + |
| 28 | +## Why Port Restrictions Still Matter (Supporting Arguments) |
| 29 | + |
| 30 | +**1. Squid's official security guidance** ([SecurityPitfalls](https://wiki.squid-cache.org/SquidFaq/SecurityPitfalls)): |
| 31 | +> "Safe_Ports prevents people from making requests to any of the registered protocol ports. SSL_Ports along with the CONNECT ACL prevents anyone from making an unfiltered tunnel to any of the otherwise safe ports." |
| 32 | +
|
| 33 | +**2. CMU SEI recommends port-based egress filtering** ([Best Practices](https://www.sei.cmu.edu/blog/best-practices-and-considerations-in-egress-filtering/)): |
| 34 | +- Block SMB (445)—would have limited WannaCry spread |
| 35 | +- Restrict DNS (53)—prevents participation in DDoS like 2016 Dyn attack |
| 36 | +- Block IRC (6660-6669)—common C2 channel |
| 37 | + |
| 38 | +**3. Defense-in-depth principle**: Forces attackers to use sophisticated techniques rather than obvious ports. |
| 39 | + |
| 40 | +## The Real Security: Domain Allowlist |
| 41 | + |
| 42 | +Port restrictions fail when attackers control infrastructure on port 443. Domain allowlists don't: |
| 43 | + |
| 44 | +``` |
| 45 | +CONNECT attacker.com:443 |
| 46 | + → Port 443? ✓ |
| 47 | + → Domain in allowlist? ✗ DENIED |
| 48 | +``` |
| 49 | + |
| 50 | +**Even this has limits.** [DNS tunneling](https://www.paloaltonetworks.com/cyberpedia/what-is-dns-tunneling) can exfiltrate data through allowed DNS servers by encoding data in queries. Mitigation requires DNS traffic analysis, not just filtering. |
| 51 | + |
| 52 | +## Security Layers Compared |
| 53 | + |
| 54 | +| Layer | What It Blocks | Bypass Method | |
| 55 | +|-------|----------------|---------------| |
| 56 | +| Port restriction | SSH:22, SMTP:25, DB:3306 | Run service on 443 | |
| 57 | +| Domain allowlist | Non-whitelisted domains | Compromise allowed domain, DNS tunneling | |
| 58 | +| SSL Bump/DPI | Malicious content on allowed domains | Performance cost, cert complexity | |
| 59 | + |
| 60 | +## Conclusion |
| 61 | + |
| 62 | +Port restrictions are **not security theater, but not primary security either**. They: |
| 63 | +- Block opportunistic attacks using standard ports |
| 64 | +- Increase attacker effort and sophistication required |
| 65 | +- Align with [NIST SP 800-41](https://nvlpubs.nist.gov/nistpubs/legacy/sp/nistspecialpublication800-41r1.pdf) egress filtering guidance |
| 66 | + |
| 67 | +**AWF's security relies on the domain allowlist.** Keep it minimal. Port restrictions are a useful secondary layer but won't stop a determined attacker with infrastructure on port 443. |
0 commit comments