Buying a good firewall is the easy part. The hard part is the rule base, the ordered list of permit and deny statements that decides what the firewall actually does. A new firewall starts with a dozen clean rules. Five years and three network engineers later, it often has several hundred, many with names like “temp-vendor-access” or “allow-test-2021”, and nobody can say with confidence which ones are still needed. The firewall is technically present and practically porous.
How a firewall reads its rules
Most firewalls evaluate rules top to bottom and stop at the first match. Each rule names a source, a destination, a service (protocol and port or, on next-generation firewalls, an application) and an action. If a packet matches nothing, a final implicit rule applies, and on any sensibly configured firewall that rule is “deny”.
First-match logic makes order critical. Consider two illustrative rules:
- Allow the internal user network to reach any destination on TCP 443.
- Deny the internal user network to the payment server subnet on any port.
The intent was clearly that users should not reach payment servers. But because rule 1 comes first and matches HTTPS traffic to anywhere, users can reach the payment servers’ HTTPS interfaces. Rule 2 never triggers for that traffic. It is a shadowed rule: it exists, it looks protective in an audit, and it does nothing for the traffic that matters. The fix is to put specific denies above broad allows.
Default deny, and why it is harder than it sounds
Default deny means only explicitly permitted traffic passes. Everyone agrees with the principle. In practice it fails in two ways.
First, broad rules creep in. When an application breaks during a go-live at 2 a.m., the fastest fix is “allow any to any between these two subnets”. The application works, the incident closes, and the rule stays forever. A rule base can be default deny at the bottom and effectively default allow because of a handful of any-any rules near the top.
Second, nobody knows what the application actually needs. Vendors often provide port lists that are incomplete or excessive. Doing it properly means observing traffic in a test environment, documenting the flows, and writing rules for those flows only.
Signs a rule base has decayed
- Zero-hit rules. Most firewalls count how often each rule matches. A rule with no hits in six months probably belongs to a decommissioned system, though check for rarely used flows such as quarter-end batch jobs or disaster recovery before deleting.
- Overly broad objects. Rules using “any” as source, destination or service, or address groups that have grown to include entire /16 ranges.
- Shadowed and redundant rules. Rules fully covered by an earlier rule, which can be found with rule analysis tools or careful review.
- No owner, no ticket, no expiry. If a rule cannot be traced to a change request and a business owner, nobody can safely decide whether it should exist.
Good hygiene is mostly process: every rule references a change ticket and an owner, temporary rules carry an expiry date in their name or comment, and a periodic review, quarterly or half-yearly depending on how fast the environment changes, removes what is no longer justified. Regulators and auditors in Indian banking and payments, as well as frameworks like PCI DSS, expect periodic firewall rule reviews, so this is rarely optional for regulated firms.
Egress filtering: the forgotten direction
Most organisations are strict about inbound traffic and relaxed about outbound. The typical outbound rule is “users and servers may go anywhere on 80 and 443”, and sometimes simply “anything outbound is allowed”.
That relaxed stance helps attackers at almost every stage after the initial break-in. Malware needs to reach its command server. Stolen data needs to leave. Tools need to be downloaded. All of this is outbound traffic.
Servers are the best place to start, because their legitimate outbound needs are narrow and knowable. A database server needs to reach the patch repository, the backup target and perhaps a monitoring service. It does not need to browse the internet. A web server in the DMZ answers inbound requests; it rarely needs to start outbound connections to arbitrary addresses. Restricting servers to named destinations means that if one is compromised, its malware may simply fail to call home, and an attempt to do so becomes a high-quality alert.
Useful egress rules for most networks include:
- Only approved internal DNS resolvers may send DNS queries to the internet; every other host must use them. This makes DNS logging and filtering meaningful.
- Only mail servers may send SMTP outbound, which stops infected machines from sending spam directly.
- Servers reach only an allow-list of destinations, ideally through a proxy.
- User web traffic passes through a proxy or secure web gateway that categorises and logs destinations.
Where this stops working
Egress filtering does not stop an attacker who uses an allowed destination. Malware that talks to a popular cloud storage or collaboration service over HTTPS blends in with legitimate traffic. Filtering by address also struggles with cloud services whose IP ranges change frequently, which pushes organisations toward domain-based or application-based rules on next-generation firewalls and proxies.
Rule-based control is also only as accurate as the network map behind it. When servers move to new subnets or the cloud, rules written for the old addresses silently stop applying, or keep allowing access to whatever now lives at those addresses. Tying rules to named objects, tags or identities, and reviewing them whenever infrastructure changes, keeps the rule base honest.
Written by the RP Strativa Team. The rule examples are illustrative.
Leave a Reply