Misconfigured Firewalls
A firewall is a list of decisions somebody made years ago, under time pressure, for reasons nobody wrote down. Over time it collects "temporary" rules that became permanent, rules for servers that no longer exist, broad allows added during an outage, and rules that can never match because an earlier one already decides. A firewall review regularly finds that the device everyone trusts lets through far more than the policy says. Misconfigured firewalls are the fifth common weakness; this lesson is the review checklist, and the Firewalls section later explains the mechanics in depth.
The mistakes that matter
| Misconfiguration | Effect |
|---|---|
| Default accept policy (or a final "allow any any") | everything not explicitly blocked passes: new services are exposed automatically |
| Over-broad rules: any source, any port, whole /8 ranges | admin ports reachable from the Internet, "temporary" vendor access for everyone |
| Shadowed rules | a rule meant to allow or block can never match because an earlier rule decides first (Rule Order, Shadowing and Redundancy) |
| No egress filtering | malware calls home, data leaves, internal hosts scan the Internet in your name (Egress Filtering) |
| Stale rules | rules for decommissioned hosts whose IPs are later reused by something else |
| IPv4-only policy | IPv6 traffic unfiltered or filtered by a different, forgotten ruleset |
| Management plane exposed | the firewall's own SSH or web UI reachable from untrusted interfaces |
| No logging on drops and on sensitive allows | no evidence when something happens |
Seeing the default-policy mistake
The lab below is the lab server's input chain with three allow rules (web, SSH from the admin network, ICMP). Run it with the default policy drop, then switch the policy to accept and run it again: the same three rules, but the RDP probe, the DNS query and the admin-panel probe from outside now all get in.
With drop, 4 of the 8 packets are accepted and 4 dropped by the policy; with accept, all 8 pass. A ruleset written as a list of allows only works with a default-deny policy behind it.
Reviewing a rule export in code
A review starts with an export of the rules, their hit counters and their metadata (comments, creation dates). The checker below applies the table above to the lab firewall's forward rules (synthetic export).
import ipaddress
from datetime import date
TODAY = date(2026, 2, 3)
ADMIN_PORTS = {22, 23, 3389, 5900, 5985, 5986, 8443}
policy = "accept"
rules = [ # id, src, dst, ports, action, hits in 90 days, comment, expires
(1, "0.0.0.0/0", "10.10.0.10/32", {80, 443}, "accept", 912_331, "public web", None),
(2, "0.0.0.0/0", "10.10.0.10/32", {22}, "accept", 18_204, "vendor support, temporary", date(2025, 6, 30)),
(3, "10.10.0.0/24", "0.0.0.0/0", None, "accept", 2_115_090, "staff to anywhere", None),
(4, "10.0.0.0/8", "10.10.0.30/32", {5432}, "accept", 50_118, "app servers to db", None),
(5, "10.10.0.0/24", "10.10.0.88/32", {3389}, "accept", 0, "old terminal server", None),
(6, "0.0.0.0/0", "10.10.0.1/32", {443}, "accept", 7_310, "firewall web UI", None),
]
def findings():
if policy == "accept":
yield "policy", "default policy is accept: everything not listed passes"
for rid, src, dst, ports, action, hits, comment, expires in rules:
s = ipaddress.ip_network(src)
if action != "accept":
continue
if s.prefixlen == 0 and ports and ports & ADMIN_PORTS:
yield rid, f"admin port {sorted(ports & ADMIN_PORTS)} open to any source ({comment})"
if ports is None:
yield rid, f"all ports allowed ({comment}); egress unrestricted" if ipaddress.ip_network(dst).prefixlen == 0 else f"all ports ({comment})"
if s.prefixlen <= 8 and s.prefixlen > 0:
yield rid, f"very broad source {src} ({s.num_addresses:,} addresses) for '{comment}'"
if expires and expires < TODAY:
yield rid, f"temporary rule expired on {expires} but still active"
if hits == 0:
yield rid, "no hits in 90 days: stale? confirm and remove"
if dst == "10.10.0.1/32" and s.prefixlen == 0:
yield rid, "firewall management reachable from any source"
if not any(":" in r[1] for r in rules):
yield "ipv6", "no IPv6 rules: check whether IPv6 is forwarded and how it is filtered"
for where, text in findings():
print(f"rule {where!s:5} {text}")rule policy default policy is accept: everything not listed passes
rule 2 admin port [22] open to any source (vendor support, temporary)
rule 2 temporary rule expired on 2025-06-30 but still active
rule 3 all ports allowed (staff to anywhere); egress unrestricted
rule 4 very broad source 10.0.0.0/8 (16,777,216 addresses) for 'app servers to db'
rule 5 no hits in 90 days: stale? confirm and remove
rule 6 firewall management reachable from any source
rule ipv6 no IPv6 rules: check whether IPv6 is forwarded and how it is filtered
Every line is a question for the firewall owner, and most have quick answers: rule 2's vendor access expired seven months ago and is still used daily (by whom?), rule 4 lets sixteen million addresses talk to the database when two application servers need it, rule 6 puts the firewall's own management page on the Internet.
How misconfiguration is detected
- Regular rule reviews (quarterly is common; PCI DSS v4.0.1 requirement 1.2.7 asks for at least once every six months for in-scope network security controls), from an export, with the business owner of each rule.
- Hit counters: rules with zero hits over a long period are candidates for removal; rules with unexpectedly many hits are worth a look.
- Change control: every rule change has a ticket, a reason, an owner and, for temporary rules, an expiry the tooling enforces.
- Testing from outside and inside: scans from each zone compared with the policy matrix (Topology Mapping) catch rules that allow more than intended.
- Configuration drift tools and firewall analysers that compute shadowing and over-permissive rules automatically.
How it is fixed
- Default deny in both directions; explicit allows only.
- Narrow every allow to the sources, destinations and ports the policy matrix names.
- Remove stale, shadowed and expired rules (after confirming with counters and owners).
- One policy for IPv4 and IPv6 (
inettables in nftables, nftables). - Management only from a management network or bastion.
- Log drops and sensitive allows, and send the logs somewhere they are read.
Pitfalls
- Cleaning up without counters or owners and breaking a monthly batch job that hits its rule once a month: look at a full business cycle before removing.
- Reviewing only the network firewall: host firewalls, cloud security groups and Kubernetes network policies are firewalls too.
- Trusting comments: the comment says "app servers"; the source says
10.0.0.0/8. - Fixing the order of rules by hand on a device that is managed by a central tool, which overwrites the fix at the next push.
Practice
1. In the lab, with policy accept and the "new connections" packets, which packets get in only because of the policy?
The ping is accepted by rule 3 either way. The policy alone lets in the SSH attempt from outside (198.51.100.9), the RDP probe, the DNS query and the admin-panel probe (8443): 4 packets, all of which drop would have stopped.
2. Rewrite rule 4 of the export to follow least privilege.
Source = the two application servers (for example 10.10.0.10/32 and a second app server), destination 10.10.0.30/32, port 5432, plus pg_hba.conf on the database restricted to the same addresses and requiring TLS.
3. Rule 5 has zero hits. What do you do before deleting it?
Check whether 10.10.0.88 still exists (inventory, DNS, ARP), ask the rule's owner, check counters over a full business cycle; then disable it (with logging) for a period before deleting it, in case something monthly depends on it.
Test yourself
Why is a default-accept policy dangerous even when the allow rules are correct?
- It slows the firewall
- Everything not explicitly blocked passes, so every new or forgotten service is exposed
- It blocks replies
- It disables logging
How many addresses does the source 10.0.0.0/8 in rule 4 cover?
- 256
- 65,536
- 16,777,216
- 4,294,967,296
What is the right handling for a 'temporary' rule?
- Leave it until someone complains
- Give it an owner and an expiry that the tooling enforces
- Hide it in a comment
- Make it the first rule