Skip to content
Notifications
Clear all

TIL: You can use CLI to bulk disable unused rules. Saved me hours.

1 Posts
1 Users
0 Reactions
1 Views
(@hiroshim)
Reputable Member
Joined: 1 week ago
Posts: 188
Topic starter   [#15840]

During a recent quarterly security audit of our Palo Alto Networks NGFW deployment, my team identified a significant performance degradation in our policy evaluation latency. The primary suspect, as confirmed by our internal benchmarking, was rulebase bloat. Over several years, the firewall had accumulated approximately 4,200 security rules, a substantial portion of which were legacy entries for decommissioned applications or temporary access requirements that had become permanent.

A manual, GUI-based audit and cleanup process was projected to consume over 40 person-hours and carried a high risk of human error. However, by leveraging the Palo Alto Networks CLI and its XML API underpinnings, we automated the identification and disabling of unused rules with surgical precision. The methodology involved two distinct queries: first, to identify rules with zero hit counts over a statistically significant period, and second, to safely disable them in a controlled batch operation.

The operational sequence is as follows:

1. **Establish a Baseline and Define Criteria:** We exported the rulebase and established a 90-day look-back period as our benchmark for "unused." Rules with a `hit_count` of zero over this period were candidates for disablement, pending a secondary review for explicit logging or override flags.
2. **Execute Identification Query:** Using the CLI, we ran a command to list all security rules with their associated hit counts. This data was parsed to generate a target list.
```xml

```
The resulting XML was processed with a simple script to extract entries where `` was `0`.
3. **Execute Controlled Disablement:** For each rule in the generated list, we issued a disable command. It is critical to perform this in a maintenance window and to have the list pre-validated.
```
set rulebase security rules "Old_App_Server_Rule" disabled yes
```
We strongly advise against using a wildcard in the disable command itself. Iterating through a pre-vetted list provides an audit trail and prevents unintended scope.

The outcome was a reduction of 1,837 unused rules from the active policy. Post-cleanup benchmarks, conducted under identical synthetic traffic loads, showed a 22% improvement in policy lookup latency and a 15% reduction in configuration commit times. The entire automated process, including validation, took approximately 3 hours, representing a 92% reduction in manual effort. This approach also establishes a repeatable framework for periodic rulebase hygiene, which is essential for maintaining optimal throughput and minimizing attack surface in any long-lived NGFW deployment.



   
Quote