ACL and Firewall Rule Analysis
Vendor-agnostic rule analysis for access control lists and firewall policies.
Unlike vendor-specific firewall audit skills that evaluate platform features
(App-ID, Security Profile Groups, zone protection), this skill focuses on
universal rule patterns that apply across all platforms: shadowed rules,
redundant rules, overly permissive rules, and unused rules.
Covers ACL-based platforms (Cisco IOS/IOS-XE/ASA, Juniper JunOS, Arista EOS)
and policy-based firewalls (Palo Alto PAN-OS, Fortinet FortiGate, Check Point).
The analysis algorithms are vendor-agnostic — only the rule retrieval commands
differ by platform.
Commands use inline labels [Cisco], [JunOS], [EOS], [PAN-OS],
[FortiGate], [CheckPoint] where syntax diverges. Unlabeled statements
apply universally. See references/cli-reference.md for full command tables
and references/rule-patterns.md for detection algorithm details.
When to Use
- - Post-migration rule cleanup after converting from one platform to another
- Periodic rulebase hygiene to remove accumulated technical debt
- Compliance preparation requiring rule-level justification and minimal privilege
- Incident investigation — determining whether a rule permitted malicious traffic
- Change validation after rulebase modifications to confirm no shadowed rules
- Capacity optimization — reducing rule count to improve lookup performance
- Merger/acquisition integration — consolidating overlapping rulebases
Prerequisites
- - Read-only access to the target device via SSH, console, or API
- Rulebase with hit counters enabled (most platforms enable by default)
- For unused rule detection: hit count data accumulated over an extended period
(30+ days minimum, 90 days recommended for seasonal traffic patterns)
- - Knowledge of intended security policy — which traffic should be permitted
and which should be denied between network segments
- - Understanding of implicit deny behavior for the platform (varies — see
Troubleshooting)
Procedure
Follow this analysis flow sequentially. Each step builds on prior findings.
The procedure moves from data collection through pattern detection to
consolidated recommendations.
Step 1: Collect Rulebase
Retrieve the full ACL or firewall policy from the target device.
[Cisco] IOS/IOS-XE:
CODEBLOCK0
[Cisco] ASA:
CODEBLOCK1
[JunOS]
CODEBLOCK2
[EOS]
CODEBLOCK3
[PAN-OS]
CODEBLOCK4
[FortiGate]
CODEBLOCK5
[CheckPoint] SmartConsole CLI or Expert mode:
CODEBLOCK6
Record each rule: sequence number/name, match criteria (source, destination,
protocol, port/service), action (permit/deny/drop/reject), and hit count.
Normalize the data into a common format for analysis.
Step 2: Identify Shadowed Rules
A rule is shadowed when a preceding rule matches all traffic that the
shadowed rule would match. The shadowed rule never triggers because the
earlier rule always matches first.
Detection algorithm:
- 1. For each rule R at position N, examine all rules at positions 1 through N-1.
- If any preceding rule P has match criteria that is a superset of R's
criteria and the same or broader action scope, then R is shadowed by P.
- 3. A superset means P's source contains R's source, P's destination contains
R's destination, and P's service/port contains R's service/port.
Critical case: A permit rule shadowing a deny rule means traffic intended
to be blocked is actually permitted. This is a security gap — flag as Critical.
Benign case: A deny rule shadowing another deny rule is a redundancy issue,
not a security gap — flag as Medium.
Verify suspected shadows by checking hit counts: a truly shadowed rule has
zero hits despite the traffic pattern existing in the network.
Step 3: Detect Overly Permissive Rules
Identify rules with excessively broad match criteria that violate least
privilege. Risky patterns by platform:
ACL platforms (Cisco, JunOS, EOS):
- -
permit ip any any — allows all IPv4 traffic, bypasses all filtering - INLINECODE3 where subnet is /8 or larger
- INLINECODE4 — unrestricted source to
sensitive service (e.g., SSH, RDP, SQL)
Policy platforms (PAN-OS, FortiGate, CheckPoint):
- - Source
any + Destination any + Action INLINECODE7 - Application/service set to
any or INLINECODE9 - Broad service groups containing dozens of ports
For each overly permissive rule found, check its hit count and traffic logs
to determine actual usage patterns. Many "any/any" rules exist as legacy
migration artifacts that can be narrowed to observed traffic.
Step 4: Find Unused Rules
Unused rules are those with zero hit count over an extended observation
period.
[Cisco] Check hit counts inline with show access-lists output.
[JunOS] show firewall filter <name> counter — per-term counters.
[EOS] show access-lists counters — per-entry match counts.
[PAN-OS] INLINECODE13
[FortiGate] diagnose firewall iprope list — per-policy packet/byte counts.
[CheckPoint] SmartConsole → Policy → hit count column, or INLINECODE15
Caveats for unused rule detection:
- - Hit counters reset on device reboot — verify uptime before concluding
a rule is unused
- - Seasonal traffic (quarterly reports, annual processes) may not appear in
30-day windows — extend observation to 90+ days when possible
- - Backup/failover paths only activate during outages — low hit count does
not mean the rule is unnecessary
- - Unused deny rules are low-risk findings; unused permit rules waste rulebase
space and may indicate abandoned access that should be revoked
Step 5: Identify Redundant Rules
Redundant rules have overlapping match criteria and the same action. They
increase rulebase complexity without adding security value.
Detection approach:
- 1. Group rules by action (permit/deny).
- Within each group, compare pairs for overlapping source, destination, and
service criteria.
- 3. If rule A's match criteria is a subset of rule B's and both have the same
action, rule A is redundant (B already covers it).
- 4. If two rules have identical match criteria and the same action, one is a
direct duplicate.
Merge candidates: rules with adjacent or overlapping source/destination
ranges and the same action can often be consolidated into a single rule with
a summarized address range.
Step 6: Rule Ordering Optimization
Rule ordering affects both security and performance.
Performance optimization: Place highest-hit-count rules near the top.
ACL platforms evaluate rules sequentially — a rule matching 80% of traffic at
position 50 forces 49 unnecessary comparisons per packet.
Security optimization: Place most-specific deny rules before broader
permit rules to ensure explicit blocks take precedence.
Conflict analysis: When a permit rule and a deny rule match the same
traffic, the first-match rule determines the outcome. Identify all
permit/deny conflicts and verify the intended rule wins by position.
Review current ordering:
- 1. Sort rules by hit count (descending).
- Compare current position against hit-count-optimal position.
- Identify rules where reordering would improve performance without
changing security posture.
- 4. Flag any reordering that would change effective policy (a permit moving
above a deny or vice versa) — these require explicit approval.
Step 7: Generate Consolidated Recommendations
Compile findings from Steps 2–6 into a prioritized remediation list.
Prioritization order:
- 1. Critical: Shadowed deny rules (security gap) and any/any permits
- High: Overly permissive rules with active traffic, unused permit rules
- Medium: Redundant rules, suboptimal ordering, unused deny rules
- Low: Cosmetic issues (naming, comments, organization)
For each finding, document: the rule identifier, the finding category, the
specific risk, and the recommended action (remove, narrow, reorder, merge).
Threshold Tables
Rule Risk Severity Classification
| Finding | Severity | Rationale |
|---|
| Permit rule shadowing a deny rule | Critical | Traffic intended to be blocked is permitted |
| INLINECODE16 / any-any-allow |
Critical | No filtering — all traffic passes |
| Broad subnet permit (source or dest ≥/8) | High | Overly wide scope; likely exceeds intent |
| Unused permit rule (0 hits, 30+ days) | High | Abandoned access — potential unauthorized path |
| Permit with
any source to sensitive service | High | Unrestricted access to high-risk ports |
| Redundant rules (same action, overlapping match) | Medium | Complexity without security value |
| Suboptimal rule ordering (high-hit rule low in list) | Medium | Performance impact on sequential evaluation |
| Shadowed deny by another deny | Medium | Redundancy, not a security gap |
| Unused deny rule (0 hits, 30+ days) | Low | Minimal risk; cleanup recommended |
| Missing rule comments/descriptions | Low | Maintainability concern |
Hit Count Staleness Thresholds
| Observation Period | Confidence | Action |
|---|
| < 7 days | Very Low | Insufficient data — do not remove rules based on hit count |
| 7–29 days |
Low | Flag for review; extend observation period |
| 30–89 days | Moderate | Reasonable basis for unused rule identification |
| 90+ days | High | Strong evidence for rule removal or narrowing |
| 180+ days | Very High | Recommend removal with change control documentation |
Decision Trees
Remediation Priority
CODEBLOCK7
Rule Reordering Safety Check
CODEBLOCK8
Report Template
CODEBLOCK9
Troubleshooting
Hit Counters Reset After Reboot
Most platforms reset ACL/policy hit counters on reboot. Before concluding
a rule is unused, verify device uptime:
[Cisco] show version | include uptime,
[JunOS] show system uptime,
[EOS] show uptime,
[PAN-OS] show system info | match uptime,
[FortiGate] get system performance status,
[CheckPoint] cpstat os -f ifconfig.
If uptime is less than the desired observation period, hit count data is
incomplete.
ACL vs Firewall Policy Semantic Differences
ACL-based platforms (Cisco IOS, EOS) evaluate rules top-to-bottom with
first-match semantics. Firewall policy platforms (PAN-OS, FortiGate,
CheckPoint) also use first-match but have additional dimensions (zones,
applications, user identity) that affect matching. Shadowed rule detection
must account for all match dimensions on policy platforms, not just
source/destination/port.
Implicit Deny Handling Varies by Platform
[Cisco] ACLs have an implicit deny ip any any at the end (not shown
in the ACL output). [JunOS] Firewall filters have an implicit discard
at the end of each term list. [EOS] Follows Cisco convention with
implicit deny. [PAN-OS] Has configurable interzone-default and
intrazone-default rules (deny and allow respectively). [FortiGate]
Implicit deny at end of policy list. [CheckPoint] Implicit drop rule
at end of policy (configurable in SmartConsole).
Account for implicit deny when analyzing rule coverage — the absence of an
explicit deny at the bottom is intentional on most platforms.
Large Rulebases (500+ Rules)
Manual analysis of large rulebases is impractical. Export the rulebase
programmatically for automated analysis:
[Cisco] Parse show access-lists output.
[PAN-OS] Use XML API to export the full policy as structured data.
[FortiGate] Use REST API (/api/v2/cmdb/firewall/policy).
[CheckPoint] Use Management API (mgmt_cli show access-rulebase).
Prioritize analysis by hit count — start with the highest-traffic rules
and work down.
False Positives in Shadowed Rule Detection
Object groups, address groups, and nested service groups can create false
positive shadow detections. When rule A uses an address group and rule B
uses individual addresses that are members of that group, automated tools
may report B as shadowed. Expand all groups to their member objects before
running shadow comparisons.
ACL和防火墙规则分析
针对访问控制列表和防火墙策略的厂商无关规则分析。与评估平台特性(应用ID、安全配置文件组、区域保护)的特定厂商防火墙审计技能不同,本技能专注于适用于所有平台的通用规则模式:被遮蔽规则、冗余规则、过度宽松规则和未使用规则。
涵盖基于ACL的平台(Cisco IOS/IOS-XE/ASA、Juniper JunOS、Arista EOS)和基于策略的防火墙(Palo Alto PAN-OS、Fortinet FortiGate、Check Point)。分析算法与厂商无关——仅规则检索命令因平台而异。
命令在语法不同处使用内联标签 [Cisco]、[JunOS]、[EOS]、[PAN-OS]、[FortiGate]、[CheckPoint]。未标记的语句通用适用。完整命令表请参见 references/cli-reference.md,检测算法详情请参见 references/rule-patterns.md。
使用场景
- - 从一个平台迁移到另一个平台后的迁移后规则清理
- 定期规则库维护以清除累积的技术债务
- 合规性准备,需要规则级理由和最小权限
- 事件调查——确定规则是否允许了恶意流量
- 规则库修改后的变更验证,确认没有产生被遮蔽规则
- 容量优化——减少规则数量以提高查找性能
- 并购整合——合并重叠的规则库
前提条件
- - 通过SSH、控制台或API对目标设备具有只读访问权限
- 已启用命中计数器的规则库(大多数平台默认启用)
- 对于未使用规则检测:需要长期累积的命中计数数据(至少30天,季节性流量模式建议90天)
- 了解预期的安全策略——哪些流量应在网段之间允许,哪些应拒绝
- 了解平台的隐式拒绝行为(因平台而异——请参阅故障排除部分)
操作步骤
按顺序执行此分析流程。每个步骤都基于之前的发现。流程从数据收集到模式检测,再到综合建议。
步骤1:收集规则库
从目标设备检索完整的ACL或防火墙策略。
[Cisco] IOS/IOS-XE:
show ip access-lists
show access-lists
[Cisco] ASA:
show access-list
show running-config access-list
[JunOS]
show configuration firewall family inet filter
show firewall filter
[EOS]
show ip access-lists
show access-lists counters
[PAN-OS]
show running security-policy
[FortiGate]
get firewall policy
[CheckPoint] SmartConsole CLI或Expert模式:
fw stat -l
记录每条规则:序号/名称、匹配条件(源、目标、协议、端口/服务)、动作(允许/拒绝/丢弃/拒绝)和命中计数。将数据标准化为通用格式进行分析。
步骤2:识别被遮蔽规则
当一条前置规则匹配了被遮蔽规则将匹配的所有流量时,该规则即为被遮蔽。被遮蔽规则永远不会触发,因为较早的规则总是先匹配。
检测算法:
- 1. 对于位置N处的每条规则R,检查位置1到N-1的所有规则。
- 如果任何前置规则P的匹配条件是R条件的超集,且具有相同或更宽的动作范围,则R被P遮蔽。
- 超集意味着P的源包含R的源,P的目标包含R的目标,且P的服务/端口包含R的服务/端口。
关键情况: 允许规则遮蔽拒绝规则意味着本应被阻止的流量实际上被允许了。这是一个安全漏洞——标记为严重。
良性情况: 拒绝规则遮蔽另一条拒绝规则是冗余问题,而非安全漏洞——标记为中。
通过检查命中计数来验证疑似被遮蔽规则:真正被遮蔽的规则在网络中存在该流量模式的情况下命中计数为零。
步骤3:检测过度宽松规则
识别匹配条件过于宽泛、违反最小权限原则的规则。各平台的风险模式:
ACL平台(Cisco、JunOS、EOS):
- - permit ip any any — 允许所有IPv4流量,绕过所有过滤
- permit ip any <宽子网>,其中子网为/8或更大
- permit tcp any any eq <高风险端口> — 对敏感服务(如SSH、RDP、SQL)无限制源
策略平台(PAN-OS、FortiGate、CheckPoint):
- - 源 any + 目标 any + 动作 allow
- 应用程序/服务设置为 any 或 all
- 包含数十个端口的宽泛服务组
对于每条发现的过度宽松规则,检查其命中计数和流量日志以确定实际使用模式。许多any/any规则是遗留迁移产物,可以缩小到观察到的流量范围。
步骤4:查找未使用规则
未使用规则是在较长的观察期内命中计数为零的规则。
[Cisco] 在 show access-lists 输出中内联检查命中计数。
[JunOS] show firewall filter <名称> counter — 逐项计数器。
[EOS] show access-lists counters — 逐条目匹配计数。
[PAN-OS] show rule-hit-count vsys vsys1 security rules all
[FortiGate] diagnose firewall iprope list — 逐策略数据包/字节计数。
[CheckPoint] SmartConsole → 策略 → 命中计数列,或 cpstat fw -f policy
未使用规则检测的注意事项:
- - 设备重启时命中计数器重置——在断定规则未使用前请验证运行时间
- 季节性流量(季度报告、年度流程)可能不会出现在30天窗口内——尽可能将观察期延长至90天以上
- 备份/故障切换路径仅在中断期间激活——低命中计数并不意味着规则不必要
- 未使用的拒绝规则是低风险发现;未使用的允许规则浪费规则库空间,可能表示应撤销的废弃访问权限
步骤5:识别冗余规则
冗余规则具有重叠的匹配条件和相同的动作。它们增加了规则库的复杂性而没有增加安全价值。
检测方法:
- 1. 按动作(允许/拒绝)对规则进行分组。
- 在每个组内,比较成对规则的源、目标和服务条件的重叠情况。
- 如果规则A的匹配条件是规则B的子集,且两者具有相同动作,则规则A是冗余的(B已覆盖它)。
- 如果两条规则具有完全相同的匹配条件和相同的动作,则其中一条是直接重复。
可合并候选:具有相邻或重叠源/目标范围且相同动作的规则通常可以合并为一条具有汇总地址范围的规则。
步骤6:规则排序优化
规则排序影响安全性和性能。
性能优化: 将命中计数最高的规则放在顶部附近。ACL平台按顺序评估规则——位于位置50的规则匹配80%的流量会导致每个数据包进行49次不必要的比较。
安全优化: 将最具体的拒绝规则放在更宽泛的允许规则之前,以确保显式阻止优先。
冲突分析: 当允许规则和拒绝规则匹配相同的流量时,先匹配的规则决定结果。识别所有允许/拒绝冲突,并验证预期规则按位置获胜。
审查当前排序:
- 1. 按命中计数(降序)对规则排序。
- 将当前位置与命中计数最优位置进行比较。
- 识别在不改变安全态势的情况下重新排序可提高性能的规则。
- 标记任何会改变有效策略的重新排序(允许移到拒绝之上或反之)——这些需要明确批准。
步骤7:生成综合建议
将步骤2-6的发现编译成优先级的修复列表。
优先级顺序:
- 1. 严重: 被遮蔽的拒绝规则(安全漏洞)和any/any允许
- 高: 具有活跃流量的过度宽松规则、未使用的允许规则
- 中: 冗余规则、次优排序、未使用的拒绝规则
- 低: 外观问题(命名、注释、组织)
对于每个发现,记录:规则标识符、发现类别、具体风险和建议操作(删除、缩小、重新排序、合并)。
阈值表
规则风险严重性分类
| 发现 | 严重性 | 理由 |
|---|
| 允许规则遮蔽拒绝规则 | 严重 | 本应被阻止的流量被允许 |
| permit ip any any / any-any-allow |
严重 | 无过滤——所有流量通过 |
| 宽子网允许(源或目标≥/8) | 高 | 范围过宽;可能超出预期 |
| 未使用的允许规则(0命中,30天以上) | 高 | 废弃访问——潜在未授权路径 |
| 源为any的允许到敏感服务 | 高 | 对高风险端口的无限制访问 |
| 冗余规则(相同动作,重叠匹配) | 中 | 复杂性而无安全价值 |
| 次优规则排序(高命中规则在列表底部) | 中 | 对顺序评估的性能影响 |
| 拒绝规则被另一条拒绝规则遮蔽