Firewall Rule Cleanup: Shadowed, Unused and Overly Broad Rules

How do you simplify a firewall rule base? Hit count and shadowing analysis, a disable–monitor–delete flow, rule owner records and a review list.
Technical summary
Technology
NGFW, security policy, hit count, FortiOS, PAN-OS, Cisco ASA
Topic
Auditing and safely cleaning up an accumulated firewall rule set
Level
Intermediate–advanced
Prerequisites
  • Read access to the firewall management interface
  • At least several months of traffic log history
  • A change management process
In this article7 sections

Rules have been added to the firewall for years, and none have been deleted. There are hundreds of lines and nobody knows which ones still serve a business need. At this point, doing the cleanup by guesswork has two outcomes: either an application stops or nobody dares to touch it. Below we explain step by step how to find shadowed, unused, duplicate and overly broad rules with data, and in what order and with what rollback safeguard to remove them.

Why the rule set bloats, and what it costs

The reasons are the same in almost every organization. Temporary access opened for a project isn’t closed. A server is moved, and the rule written for the old IP stays in place. A broad rule opened on an outage night to “get it working first” becomes permanent. An application is decommissioned but its rules aren’t deleted because nobody owns them. Look at the change requests: it’s always “add”; “remove” almost never comes.

The cost of this accumulation is concrete:

  • The attack surface grows. When a decommissioned server’s IP is given to another system, the old allow rule opens a path to the new system that nobody wanted. This is the common surprise.
  • Audit findings come up. A rule whose reason for existing can’t be explained becomes a direct finding in a configuration audit; predicting the effect of a new change also becomes harder.
  • Troubleshooting goes to the wrong place. A newly written rule never matches because of a broad rule above it; the team looks at the wrong line for hours.
  • Management slows down. Even though modern NGFWs optimize matching, very large, object-heavy policies lengthen compile time, management interface response and HA synchronization.

Telling apart shadowed, unused, duplicate and overly broad rules

Before you start deleting, put each rule in a category. The category determines which analysis to do and how risky removal is.

Rule type Definition Detection method Removal risk
Shadowed A rule above catches the same traffic first Policy analysis tool, scope comparison Low; the rule never matches anyway
Unused Never matched during the measurement window Hit count, last used date Medium; annual jobs may be missed
Duplicate / mergeable Similar rules written for the same purpose Source-destination-service comparison Low to medium
Overly broad Any source/destination/service or a broad subnet Building the real traffic profile from logs High; an outage if narrowing is done wrong
Expired temporary Opened for a specific project or date Rule description, request record Low; if the owner confirms

Shadowing is a logic error. Rules are read top to bottom and the first match applies. An allow rule with source 10.10.0.0/16 and service any makes a narrower rule written below it for 10.10.5.0/24 completely ineffective. The reverse is more dangerous: a “deny” rule below never kicks in because of a broad allow above it, and the team thinks it’s protected. On paper there’s a block. In the traffic there isn’t. Most vendors’ management tools or separate policy analysis software include a shadowing report; if not, you need to export the rules with their source, destination, service and application fields and compare scopes.

Overly broad rules carry the most risk but can’t be deleted, only narrowed. A rule like “any from the DMZ to the internal network” is, in reality, mostly used for a few servers and a few ports. The only way to prove this is log data.

Usage analysis with hit counts and log data

The hit count shows how many times a rule has matched, and the last hit date when it last matched. Before trusting the number, check three things:

  1. Since when has the counter been counting? On some platforms, a reboot, firmware upgrade, HA failover or manually clearing the counters resets hit counts. “0 hits” means something only if the counter’s start date is known.
  2. Is the window long enough? Month-end close, the annual audit, a failover test to the secondary data center or seasonal applications don’t show up in a short window. At least 90 days, and in critical environments a year of log history, is preferred.
  3. Did you look at every member of the cluster? In active-active clusters or policies distributed across multiple firewalls, counters may be kept per device. A zero on one device doesn’t mean the rule isn’t used.

Access to the data varies by vendor. On Fortinet FortiGate, the “Hit Count”, “Bytes” and “Last Used” columns in the policy list provide this information. On Palo Alto Networks PAN-OS, Policy Optimizer lists unused rules; the CLI equivalent is below. On Cisco ASA, the hitcnt value is shown for each ACE.

# Palo Alto PAN-OS: hit counts for all security rules
show rule-hit-count vsys vsys-name vsys1 rule-base security rules all

# Cisco ASA: access list lines that have never matched
show access-list | include hitcnt=0

To narrow an overly broad rule, the hit count isn’t enough; you need to see which source, destination and service combinations the rule matches. Enable end-of-session logging on the rule, send the logs to your SIEM or log manager, group them by rule ID and extract the unique source–destination–port triples. The resulting list is the draft of the narrow rules that will replace the broad rule. Building detections from the same logs is covered separately in the threat detection from firewall logs guide.

A safe cleanup flow: disable, monitor, delete

Deleting a rule directly makes rolling back harder: its position, objects, description and profile bindings are lost. When an application stops at midnight, you don’t want to try to rewrite that rule from memory. The flow works in this order:

  1. Backup and candidate list. A full configuration backup is taken before the change. Candidate rules are shared with their owners and an objection period is defined (for example, two weeks).
  2. Disable. Candidate rules aren’t deleted but disabled; the date and change record number are written in the description field. To limit the blast radius, the change is made in batches and in a maintenance window.
  3. Monitor. Unexpected blocks are watched on the default “deny” rule below the disabled rule, or on an explicitly written “deny + log” rule. Access complaints coming to the help desk are matched against the change record.
  4. Delete. If the monitoring period (typically 30–90 days) passes without problems, the rule and the address/service objects no longer used anywhere are deleted.

To disable a rule in FortiOS and leave the justification on the rule:

config firewall policy
    edit 87
        set status disable
        set comments "CHG-2026-0412: unused rule, disabled 2026-11-10, delete on 2027-01-10"
    next
end

In PAN-OS, the same operation is done with the rule’s “Disable Rule” option or in configuration mode with set rulebase security rules <rule-name> disabled yes, and requires a commit; on devices using multiple vsys, the path is set vsys vsys1 rulebase security rules <rule-name> disabled yes.

A rule ownership and expiry date standard

Doing the cleanup once doesn’t finish the job. Without a process, the same buildup comes back within two years. The lasting solution is to standardize the minimum information every rule must carry:

  • Owner: If possible a role or team rather than a person (“ERP application team”). When a person leaves, the rule isn’t left without an owner.
  • Business justification and request number: A short text explaining why the rule exists and a link to the change record.
  • Expiry date: Mandatory for temporary access; for permanent rules, used as the next review date.
  • Naming convention: The source zone, destination zone and purpose should be readable from the rule name.

Some platforms support time-bound policies. On FortiGate, when a one-time schedule object is attached to a rule, the rule doesn’t match after the end date; it’s useful for temporary vendor access. However, the expired rule stays in the list and should be deleted in the periodic review. To put this standard in place from the start in new installations, see the policy design steps in the critical checks when setting up a FortiGate article.

Periodic rule review checklist

NIST SP 800-41 Rev. 1 recommends reviewing firewall policies regularly and running policy management as a process (NIST SP 800-41 Rev. 1). Use this list in a quarterly or semi-annual review:

  • A configuration backup was taken and compared with the changes made since the previous review.
  • The date hit counters were last reset was recorded.
  • Rules that didn’t match in the measurement window were listed and sent to their owners.
  • Shadowed and duplicate rules were reported.
  • Allow rules containing any in the source, destination or service field were justified one by one.
  • Rules past their expiry date were disabled.
  • No rules are left with a missing owner or description.
  • Unused address and service objects were cleaned up.
  • Rules that were disabled and completed the monitoring period were deleted.
  • Rules for access to the management interface are limited to the management network only.
  • The review result and decisions made were recorded.

The team that writes the rule set can’t see its own blind spots. An independent eye helps here. In this context, a cybersecurity control and configuration audit can be planned together with firewall rule management, which covers rule design and operation. If you’re at the device selection stage, add the quality of policy management tools to your enterprise firewall selection criteria; the cleanup workload of the coming years depends directly on it.

Frequently asked questions

Can I delete a rule with a hit count of zero right away?

No. First verify how long the counter has been counting, make sure the measurement window covers annual and periodic jobs, and ask the rule owner. Before deleting the rule, disable it and apply a monitoring period.

What’s the difference between a shadowed rule and an unused rule?

A shadowed rule can never logically match because a broader rule above it catches the same traffic first. An unused rule is able to match, but no matching traffic arrived during the measurement window. The first is found through policy analysis, the second through usage data.

How often should rule cleanup be done?

There’s no fixed frequency; quarterly or semi-annual reviews are a common approach depending on how much changes. Once a rule ownership and expiry date standard is in place, each cycle takes less time.

How do I safely narrow a rule that contains “any”?

Enable session logging on the rule, extract the real source, destination and port combinations from the logs, and add narrow rules for these above the broad rule. After the broad rule’s match count drops to zero, disable it.

Support

Contact us for support or a discovery session on this topic.

Contact form
[email protected]

Eretek Cybersecurity

Firewall, VPN, endpoint security and threat prevention. We reduce the attack surface and measure and report the risks.

Knowledge Center

Other articles